<div id="update-checkbox" class="row update-checkbox" data-company-code="10000005980" data-type="Contractual Customer,Shipper">
<input type="checkbox" value="2" data-original-title="">
<div class="span3">
<label class="checkbox">Contractual Customer<input type="checkbox" value="2" data-original-title=""></label>
</div>
<div class="span3">
<label class="checkbox">Shipper<input type="checkbox" value="3" data-original-title=""></label>
</div>
</div>
var partyTypes = $("#update-checkbox").attr("data-type"); // gives "Contractual Customer,Shipper
$.each(partyTypes.split(','),
function(i, opt) {
//here i need to loop through all the label and checkbox inside div (id = update-checkbox) and if the party type equals to the label then check that check box
});
爲前,如果partytype =合同的客戶,然後選中相應的複選框jQuery的:遍歷一個div和comapre標籤內的所有標籤元素,檢查複選框
我看不出有任何屬性'數據黨type' –
應該是'數據type'。我認爲。 – Craftein