<ul>
<li id="RadListBox1_i2" class="rlbItem ui-draggable">
<div class="ui-draggable ui-state-default" data-shortid="1007">
<em>ProductId: </em>
<span>110-01-070-10</span>
<br>
<em>ShortID: </em>
<span class="ShortID" data-shortid="1007">1007</span>
<br>
<em>Product Defaul cat: </em>
<span class="spanDefCat" data-defcat="334">334</span>
</div>
</span>
</li>
<li id="RadListBox1_i3" class="rlbItem ui-draggable">
<li id="RadListBox1_i4" class="rlbItem ui-draggable">
</ul>
나는두 개의 데이터 속성 값을 기반으로 요소를 찾는 방법은 무엇입니까?
$("#AllProducts li:contains('ShortID:" + Product + "'):contains('" + iCategory + "')").addClass("backDefaultCat");
전에이 기능을 사용하던이 요소를 찾을 필요하지만 지금은 내가 = = X가 나는 항목이 데이터 shortid이있는 경우 점검 할 필요가 뿌리 데이터 shortid와 X 작업을 참조로 및 데이터 defcat = Y는
일부는 그냥 바로 결합 할 수 있습니다이
$("span.ShortID[data-shortid=" + Product + "] span.spanDefCat[data-defcat=" + iCategory + "]").parents("li:first").addClass("backDefaultCat");
처럼 생각합니다.
이 경우 실패합니다. http://jsfiddle.net/arunpjohny/SBhMV/3/ –
각 루프가 추가되었습니다. –
Thx 그냥 작은 오류 span의 두 번째 데이터가 data-defcat인지 확인하십시오. 내 코드를 편집하지 못했습니다. @ Arun이 실패했습니다. –