WOW!

MuCH respect and thanks to you Hector.

I am most grateful (again!).

Cheers! -Alan


On Nov 19, 1:04 pm, "Hector Virgen" <[EMAIL PROTECTED]> wrote:
> Oops, 'class' is a reserved word. I also had a typo in the function.. I
> tested this code and it works:
> $.each($(document.body).attr('class').split(' '), function(key, value)
> {
>     $('h3.' + value).addClass('foundMatch');
>
> });
>
> -Hector
>
> On Wed, Nov 19, 2008 at 10:00 AM, alanfluff
> <[EMAIL PROTECTED]>wrote:
>
>
>
> > Hey Hector,
>
> > Thanks lots for looking at this for me -- I tried it and it doesn't
> > seem to add the class.
>
> > A typo maybe? I've tried commenting out all my jQuery (not much) in
> > case it conflicted, but no change.
>
> > Thanks again very much, for your reply. Cheers, -Alan
>
> > On Nov 19, 11:35 am, "Hector Virgen" <[EMAIL PROTECTED]> wrote:
> > > This may be a little longer but it checks each body class individually:
> > > $.each($(document.body).attr('class').split(' '), function(class)
> > > {
> > >     $('h3.' + class).addClass('foundMatch');
>
> > > });
>
> > > -Hector
>
> > > On Wed, Nov 19, 2008 at 8:30 AM, alanfluff <
> > [EMAIL PROTECTED]>wrote:
>
> > > > 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