0
如果我知道屬性名稱,是否有更好的方法,更少的密集(我可以有100的OS樣本)寫這個? (「[attribute.name ==''Clear-Matt']」)。$(this).attr('cost');js xml獲取已知屬性的另一個屬性
如果沒有這個函數會在(name ==「Clear-Matt」)時停止,或者它會一直持續到色板的末尾?如果有,是否有辦法阻止它?
var swatchCost='';
$(xmldoc).find('Swatch').each(function() {
var name = $(this).attr('name');
if (name=="Clear-Matt") {
swatchCost=$(this).attr('cost');
}
});
XML:
<Swatch name="Clear" title="Clear" alt="Frame" cost="100" match=""></Swatch>
<Swatch name="Clear-Matt" title="Clear-Matt" alt="Frame" cost="11" match=""></Swatch>
<Swatch name="Blue-Orange" title="Blue-Orange" alt="Frame" cost="200" match=""></Swatch>
<Swatch name="Pink-Blue-Clear" title="Pink-Blue-Clear" alt="Frame" cost="300" match=""> </Swatch>
<Swatch name="Blue" title="Blue" alt="Frame" cost="11" match=""></Swatch>
感謝。
這很好,謝謝你的答案! – user2238083
@ user2238083不客氣... – PSL