1
データ属性でキーの値を取得するのに苦労しています。 jqueryメタデータプラグインを使用しています。jQueryメタデータ、値を取得する方法?
のjQuery:
jQuery.metadata.setType("attr", "data");
$('ul li').each(function() {
console.log($(this).metadata())
});
HTML
<ul>
<li data="{someKey:'someValue',anotherKey:'anotherValue'}">Some List Item</li>
<li data="{someKey:'someValue2',anotherKey:'anotherValue2'}">Some List Item 2</li>
<li data="{someKey:'someValue3',anotherKey:'anotherValue3'}">Some List Item 3</li>
</ul>
私は、オブジェクトを出力し、その値で取得する方法は考えているのです。私は$(this).metadata().someKey
と$(this).metadata('someKey')
を試しましたが、今はわらをつかんでいます。
完璧、ありがとう! – jyoseph
問題はありません、私の喜び。 –