I will probably use seperate classes, but I found the answer.....

$(".button").each(function(el){
    classStr = el.className;
    classes = classStr.split(' ');

    // Loop through classes and find the one that starts with icon

});




On Apr 16, 4:05 pm, "Jonathan Vanherpe (T & T NV)" <jonat...@tnt.be>
wrote:
> jonhobbs wrote:
> > Both of those would work as solutions to this problem.
>
> > However, I'd still really like to find out if there's a way to get a
> > list (array?) of all of the classes that are currently attached to an
> > element and loop through them.
>
> > It doesn't dound like it should be so hard.
>
> > Jon
>
> you could loop through all elements with $('.button'), and get their
> attr('class'), put those elements in an array, then parse that srting
> with a regex to see if you have a match.
>
> It can be done, but I just wouldn't recommend it. Use seperate classes
> like MorningZ suggested and you don't even need to use javascript if all
> you want to do is put an image in a class (that really is a job css was
> made for, javascript should just stick to the behavioural stuff).
>
> Jonathan
> --
> Jonathan Vanherpe - Tallieu & Tallieu NV - jonat...@tnt.be

Reply via email to