以下、「選択済み」のオブジェクトからスクリーンショットを見つけることができます。これは選択リストです。次のコード(jQueryを使用)でオブジェクトを受け取ります。変数を介してデータ属性値にアクセス
var addArticle = $('.add-article'); // div.add-article
// selector is a dynamic value, that defines, which select-list should be "found"
var select = addArticle.find('[data-id=' + selector + ']');
オブジェクトの選択は問題ありません。しかし、私がデータ属性値(数値は数値)を取得したいとき、私はそれらを取得することができません。
私は誰かが私の問題を理解することができ、期待した値を取得するために多くのバリエーションを試してみましたが、ここでの例
//$this.selectors is an array with all values beween data- and -id
$.each($this.selectors, function (i, el) {
//return if last needed data attribute was read
if (i == $this.lastAsInt) {
return false;
}
// "generate" data-selector
selector = '[data-' + el + '-id]';
// select = object from the image (see link), also tried with data()
location[el] = select.find(':selected').find(selector);
});
です:)
です'selector 'とすると、' []]のように 'selector' '[data-' + el + '-id]';'のようにラップする必要があります。それがあなたが必要としているものではない場合は、あなたの質問を編集して、私の場合にはこれがうまくいかないようにしようとしています。 –