user2247671
user2247671

Reputation: 243

jquery data attribute selector

I am trying select some divs where the data attribute x10 equals the variable Xmodule. I have something wrong with the selector but I don't know what is wrong.

 //find data element that matched Xmodule and display either on or off class
 $('div[data-x10=Xmodule]').each(function(){
 if (XStatus ==="2")
    {element.removeClass('off').addClass('on');}
 else
    {element.removeClass('on').addClass('off');};
  }); 

Upvotes: 1

Views: 367

Answers (1)

codingrose
codingrose

Reputation: 15709

Try this:

It should be $('div[data-x10="Xmodule]"').

Value of attribute should be passed in quotes.

Upvotes: 1

Related Questions