1
데이터 속성에서 키 값을 가져 오는 데 어려움을 겪고 있습니다. jquery 메타 데이터 플러그인을 사용하고 있습니다.jQuery 메타 데이터, 값을 얻는 방법?
jQuery를 : 나는 객체를 출력하지만, 어떻게 가치를 얻는 아무 생각이 있어요
<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>
jQuery.metadata.setType("attr", "data");
$('ul li').each(function() {
console.log($(this).metadata())
});
HTML. 나는 $(this).metadata().someKey
과 $(this).metadata('someKey')
을 시도했고, 지금 나는 빨대를 쥐고 있습니다. 사용자가 설정 한 메타 어떤 키 - 그럼 당신은 myMeta.someKey
또는 myMeta.anotherKey
에 액세스 할 수 있습니다
myMeta = $(this).metadata();
: 당신이 원하는 것처럼
완벽한 덕분에! – jyoseph
문제 없어요, 저의 기쁨. –