1
我有section
和article
顯示內容。我的代碼是:比較在HTML5中的ID
<section id = "examples">
<article id="item_1">
...
</article>
<article id="item_2">
...
</article>
<article id="item_3">
...
</article>
<article id="item_4">
...
</article>
...
</section>
我想獲得的articles
,這樣我可以比較的ID,但我越來越不確定。我的代碼是:
var compare = "item_1"
$('article').each(function(){
var pos = $('article').id;
console.log(pos) //getting undefined
if(pos == compare)
// do something
});