Thanks SO much Liam.

This works but I was looking for triggerClass to flow from the classes
found in BODY (rather than being a static class defined in jQuery).

So if BODY had classes: classOne classTwo classThee and an H3 on my
page had a class of classTwo, then the script would spot the match and
add class foundMatch to my H3.

Sorry I didn't explain that more clearly.

If you can help more, thanks again in advance and either way, thanks
for your quick and helpful reply.

Cheers, -Alan


On Nov 19, 9:45 am, Liam Potter <[EMAIL PROTECTED]> wrote:
> you won't need the if statement.
>
> $(document).ready(function(){
>         $("[EMAIL PROTECTED]'triggerClass']
> [EMAIL PROTECTED]'triggerClass']").addClass("foundMatch");
>
> });
>
> this will find the h3 with a class of triggerClass, found within a body
> tag with the class of triggerClass and add the foundMatch class to the h3.
>
> alanfluff wrote:
> > Hi folks,
>
> > I am trying to add an extra class to an element (an h3) if one of it's
> > classes matches with one of BODYs classes.
>
> > In pseudo code, I am trying to:
>
> > if BODY class includes triggerClass and H3 class includes triggerClass
> > then addClass foundMatch to h3
>
> > This is one of my quite-a-few attempts to do this -- I know this is
> > broken.
>
> > $(function() {
> >    if ($('[EMAIL PROTECTED]([EMAIL PROTECTED])]').addClass('foundMatch');
> > });
>
> > Can anyone point me in the right direction? _Really_ apologise for
> > asking this lame question, it's just I've tried so many things and
> > keep failing...
>
> > With thanks in advance for any suggestions, cheers, -Alan

Reply via email to