JQuery if/else statement matching a wildcard css name
Posted
by
Neokoenig
on Stack Overflow
See other posts from Stack Overflow
or by Neokoenig
Published on 2011-01-17T16:51:31Z
Indexed on
2011/01/17
16:53 UTC
Read the original article
Hit count: 161
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!
© Stack Overflow or respective owner