JQuery if/else statement matching a wildcard css name
- by Neokoenig
Hi All, I'm trying to write an if/else statement in jQuery which can change an elements class by matching 'IN' or 'OUT' (in this case).
I.e, I have several Divs with class='IN-something' OR class='OUT-something'.
The below would work if I new the exact CSS class, but all I'll know is whether it contains 'IN' or 'OUT'.
So like this, but works:
if ($(jRow).hasClass('IN-*'))
{jRow.attr( "class", "OUT-foo" );}
else
{jRow.attr( "class", "IN-foo");}
Ideas?
Thanks!