Hey Liam,

No worries! And I have been called a lot worse than 'Andy' ;)

Good luck in your learning of jQuery too - it is brilliant and I am
just greedy to know much more too quickly ;)

Cheers, -Alan


On Nov 19, 11:07 am, Liam Potter <[EMAIL PROTECTED]> wrote:
> I'm afraid I cannot help any further Alan, I'm still learning jQuery
> myself .
> I'd guess it would have something to do with storing the class of the
> body in a var and of the h3 in a different var.
> Compare these two var's and if they match continue to add the foundMatch
> class to the h3.
>
> I havn't tried any if statements with jquery yet so not sure how to
> structure that.
> Sorry Andy.
>
> alanfluff wrote:
> > 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