Use this
to get each article element's id
: var pos = this.id;
:
var compare = "item_1";
$('article').each(function () {
var pos = this.id;
console.log(pos);
if (pos == compare) {
alert('match');
}
});
Output:
item_1
item_2
item_3
item_4