Reputation: 46547
I have following statement
if(play == '4'){
$(this).removeAttr('data-playa');
$(this).attr("data-pausea",'5');
}
Basically it replaces data-playa="4"
to data-pausea="5"
of the current element. $(this)
referees to current anchor tag with class of article-play so $(article-play)
. I need to somehow edit this code to also apply following to all $(article-play)
elements on a page, except current one:
$(article-play).removeAttr('data-pausea');
$(article-play).attr("data-playa",'4');
So it will logically be like this
if(play == '4'){
// Apply this to current .article-play
$(this).removeAttr('data-playa');
$(this).attr("data-pausea",'5');
// Apply this to all other .article-play on a page
$(article-play).removeAttr('data-pausea');
$(article-play).attr("data-playa",'4');
}
Upvotes: 1
Views: 505
Reputation: 253506
At its simplest:
$(this).removeAttr('data-playa').attr("data-pausea",'5');
$(article-play).not(this).removeAttr('data-pausea').attr("data-playa",'4');
If you were to use the data()
method instead:
$(this).removeData('playa').data("pausea",'5');
$(article-play).not(this).removeData('pausea').data("playa",'4');
If the other elements are siblings, however:
$(this).removeData('playa').data("pausea",'5').siblings()
.removeData('pausea').data("playa",'4');
Upvotes: 3