jQuery check if element has a class begining with some string

Posted by ktMen on Stack Overflow See other posts from Stack Overflow or by ktMen
Published on 2010-04-19T14:36:33Z Indexed on 2010/04/19 15:23 UTC
Read the original article Hit count: 164

Filed under:

I need to loop through some elements in the page and then, for each one, if it had a class beginning with, for example, "C", do something.

$('#dialog li').each(function(){
    if ($(this).hasClass("^C")){
         //do something
    }
}

It may sound silly, but what selector/method should I use on the if clause? Thanks in advance.

© Stack Overflow or respective owner

Related posts about jquery-selectors