Reputation: 575
Is it possible to compare the attribute value in jQuery?
example
if( $(this).[ attribute value ] == "0")
{}
else
{}
Upvotes: 0
Views: 10041
Reputation: 700232
You can get the attribute value using the attr
method and compare it:
if ($(this).attr("attrname") == "0") {
$(this).css('background', 'red');
}
You can also use a selector to filter out elements with a specific attribute value:
$(this).filter('[attrname=0]').css('background', 'red');
Upvotes: 0
Reputation: 148110
Try this
if( $(this).attr('myattribute') == "0")
{
//Your statements
}
else
{
//Your statements
}
Upvotes: 1