[jQuery] SIMPLE (newbie) selecting TDs
Hi, I am embarrassed to say I can't find a way to select the third cell in each row of a table and add a class to it. I tried this: $('.vfOptions tr td').eq(2).addClass('status'); and it worked for the first row but not subsequent rows. So I tried this, thinking it was the correct construct perhaps $('.vfOptions tr td').(function() { $(this).eq(2).addClass('status'); }); but it failed to add class to any rows at all. I would be MOST grateful for any clues as to what I am doing wrong - thanks in advance in deed! Cheers, -Alan
[jQuery] Newbie clueTip Plugin style removal
Hi cleverer people than me... Please can someone point me in the right direction to use this brilliant plugin but have it add no stlye so I can add style to an unstyled chunk of markup? I'm calling the plugin with $('.linkToFaq a').cluetip({splitTitle: '|', width: '100px', cluetipClass: 'fdFaq', sticky: 'true'}); and fdFaq has only one rule, a border, and yet the o/p produced is the following (below my sig', a lot of style). Thanks LOTS in advance to any commenters, I'm sure it's easy and I am daft. Cheers, -Alan div style=position: absolute; z-index: 95; display: none; id=cluetip-waitimage/divdiv class=clue-right-fdFaq cluetip- fdFaq style=z-index: 96; display: block; position: absolute; width: 100px; left: 732.767px; top: 570.4px; id=cluetipdiv style=z- index: 95; opacity: 0.1; top: 1px; left: 1px; position: absolute; background-color: rgb(0, 0, 0); display: block; height: 77px; width: 100px;/divdiv style=z-index: 94; opacity: 0.1; top: 2px; left: 2px; position: absolute; background-color: rgb(0, 0, 0); display: block; height: 77px; width: 100px;/divdiv style=z-index: 93; opacity: 0.1; top: 3px; left: 3px; position: absolute; background- color: rgb(0, 0, 0); display: block; height: 77px; width: 100px;/ divdiv style=z-index: 92; opacity: 0.1; top: 4px; left: 4px; position: absolute; background-color: rgb(0, 0, 0); display: block; height: 77px; width: 100px;/divdiv style=z-index: 91; opacity: 0.1; top: 5px; left: 5px; position: absolute; background-color: rgb(0, 0, 0); display: block; height: 77px; width: 100px;/divdiv style=z-index: 90; opacity: 0.1; top: 6px; left: 6px; position: absolute; background-color: rgb(0, 0, 0); display: block; height: 77px; width: 100px;/divdiv style=overflow: visible; position: relative; z-index: 97; height: auto; id=cluetip-outerh3 id=cluetip-titleQnbsp;amp;nbsp;A/h3div id=cluetip- innerdiv id=cluetip-closea href=#Close/a/divHow come I’m not separately charged for the designnbsp;time/div/divdiv id=cluetip-extra/divdiv style=z-index: 97; display: none; id=cluetip-arrows class=cluetip-arrows/div/div
[jQuery] Finding matching classes
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
[jQuery] Re: Finding matching classes
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
[jQuery] Re: Finding matching classes
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
[jQuery] Re: How to position a footer always at bottom?
Yes, CSS can do this, you may find if your page uses floats, that this may have problems, but this is the most robust solution I have seen (cross browser) with CSS: http://www.themaninblue.com/writing/perspective/2005/08/29/ Good luck! Cheers, -Alan On Nov 19, 5:24 am, Liam Potter [EMAIL PROTECTED] wrote: I don't see the point of using jquery for this, this is all possible with pure css. howa wrote: Consider the code: !DOCTYPE HTML PUBLIC -//W3C//DTD HTML 4.01//EN http://www.w3.org/TR/html4/strict.dtd; html head title/title script type=text/javascript src=jquery-1.2.6.min.js/script script type=text/javascript $(document).ready(function() { var footer = $('#footer'); var w = ( $(window).width() - footer.width() ) / 2; footer.css('left', w); footer.css('display', 'block'); $(window).scroll(function(){ console.debug( $(window).height() ); footer.css('bottom', 0); }); }); /script style #footer{ background-color:green; height:30px; position:absolute; width:800px; bottom:0; display:none; } /style /head body pLorem ipsum dolor s.eugiat./p pLorem ipsum dolor s.eugiat./p pLorem ipsum dolor s.eugiat./p div id=footerFooter/div /body /html I want to footer always at the bottom, no matter I scoll the page. (while resize I don't care)
[jQuery] Re: Finding matching classes
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
[jQuery] Re: Finding matching classes
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
[jQuery] How to avoid triggering two patterns that match - from a JavaScript/jQuery lightweight
Hi, I am trying to limit the scope of a click trigger to the first/next matched target. This works fine if I have one container of class .expander.map but as soon as I add another, they both respond (I guessed they would ;) $('.linkify.map').click(function() { $('.expander.map').show(); }); I have tried using $(this) and .next() but likely not correctly... I am _certain_ this is stupidly simple and I am missing the obvious. Grateful if anyone can point me in the right direction. Cheers lots in advance! [I am a lightweight (little experience) when it comes to JavaScript/ jQuery, so much so that even though I have jQuery Ref and Learning books, I still have not sussed this. What am I like...]
[jQuery] Re: How to avoid triggering two patterns that match - from a JavaScript/jQuery lightweight
Thanks _lots_ for the quick reply Hector -- I'll go try that. Cheers! On Nov 12, 2:22 pm, Hector Virgen [EMAIL PROTECTED] wrote: Try $('.linkify.map:first'). That should return the first matched element. -Hector On Wed, Nov 12, 2008 at 11:04 AM, alanfluff [EMAIL PROTECTED]wrote: Hi, I am trying to limit the scope of a click trigger to the first/next matched target. This works fine if I have one container of class .expander.map but as soon as I add another, they both respond (I guessed they would ;) $('.linkify.map').click(function() { $('.expander.map').show(); }); I have tried using $(this) and .next() but likely not correctly... I am _certain_ this is stupidly simple and I am missing the obvious. Grateful if anyone can point me in the right direction. Cheers lots in advance! [I am a lightweight (little experience) when it comes to JavaScript/ jQuery, so much so that even though I have jQuery Ref and Learning books, I still have not sussed this. What am I like...]
[jQuery] Re: How to avoid triggering two patterns that match - from a JavaScript/jQuery lightweight
Almost what I want - but the first map is always the one shown, I could have explained better, my bad, sorry. Pseudo code for what I have: . . click-to-trigger-map mapOne[div] . . click-to-trigger-map mapTwo[div] . . etc The :first seems to make mapOne display, regardless which click-to- trigger I click. It looks as if the scope of the :first is the whole DOM and no starting from the point where the click occurred and affecting the first instance after it (which is what I want). Thanks in advance for any further help! Cheers, -Alan On Nov 12, 2:36 pm, alanfluff [EMAIL PROTECTED] wrote: Thanks _lots_ for the quick reply Hector -- I'll go try that. Cheers! On Nov 12, 2:22 pm, Hector Virgen [EMAIL PROTECTED] wrote: Try $('.linkify.map:first'). That should return the first matched element. -Hector On Wed, Nov 12, 2008 at 11:04 AM, alanfluff [EMAIL PROTECTED]wrote: Hi, I am trying to limit the scope of a click trigger to the first/next matched target. This works fine if I have one container of class .expander.map but as soon as I add another, they both respond (I guessed they would ;) $('.linkify.map').click(function() { $('.expander.map').show(); }); I have tried using $(this) and .next() but likely not correctly... I am _certain_ this is stupidly simple and I am missing the obvious. Grateful if anyone can point me in the right direction. Cheers lots in advance! [I am a lightweight (little experience) when it comes to JavaScript/ jQuery, so much so that even though I have jQuery Ref and Learning books, I still have not sussed this. What am I like...]
[jQuery] Re: How to avoid triggering two patterns that match - from a JavaScript/jQuery lightweight
Wow! Thanks Hector - I am most grateful to you. I will try this tomorrow and let you know :) Cheers, -Alan On Nov 12, 4:14 pm, Hector Virgen [EMAIL PROTECTED] wrote: I think maybe something like this might work: $('.maps').click(function() { $(this).next('.expander.map').show(); }); That would expand the next map based on whatever was clicked. I hope this helps :) -Hector On Wed, Nov 12, 2008 at 12:04 PM, alanfluff [EMAIL PROTECTED]wrote: Yep. Get that. Tks. However, I am trying to make my code re-useable, right now there are two sets of trigger-and-map markup. I will have 10 to 20. I was hoping to find a jQ construct that would say: if a map-trigger is clicked, I will expand the map that immediately follows it in the DOM. That way I would not need to have an #id for each trigger/map in HTML and the jQ would be one lump of code, not a set of identical lumps, each one handling one of the trigger-and-maps. Thanks again for your reply - sorry if I'm not explaining myself well. Cheers, -Alan On Nov 12, 2:53 pm, Hector Virgen [EMAIL PROTECTED] wrote: You're right, $('.linkify.map:first') will always return the first element that matches linkify.map. If you want to make it in respect to a container, try $('#container').find('.linkify.map') -Hector On Wed, Nov 12, 2008 at 11:49 AM, alanfluff [EMAIL PROTECTED]wrote: Almost what I want - but the first map is always the one shown, I could have explained better, my bad, sorry. Pseudo code for what I have: . . click-to-trigger-map mapOne[div] . . click-to-trigger-map mapTwo[div] . . etc The :first seems to make mapOne display, regardless which click-to- trigger I click. It looks as if the scope of the :first is the whole DOM and no starting from the point where the click occurred and affecting the first instance after it (which is what I want). Thanks in advance for any further help! Cheers, -Alan On Nov 12, 2:36 pm, alanfluff [EMAIL PROTECTED] wrote: Thanks _lots_ for the quick reply Hector -- I'll go try that. Cheers! On Nov 12, 2:22 pm, Hector Virgen [EMAIL PROTECTED] wrote: Try $('.linkify.map:first'). That should return the first matched element. -Hector On Wed, Nov 12, 2008 at 11:04 AM, alanfluff [EMAIL PROTECTED]wrote: Hi, I am trying to limit the scope of a click trigger to the first/next matched target. This works fine if I have one container of class .expander.map but as soon as I add another, they both respond (I guessed they would ;) $('.linkify.map').click(function() { $('.expander.map').show(); }); I have tried using $(this) and .next() but likely not correctly... I am _certain_ this is stupidly simple and I am missing the obvious. Grateful if anyone can point me in the right direction. Cheers lots in advance! [I am a lightweight (little experience) when it comes to JavaScript/ jQuery, so much so that even though I have jQuery Ref and Learning books, I still have not sussed this. What am I like...]
[jQuery] Re: How to avoid triggering two patterns that match - from a JavaScript/jQuery lightweight
:D Thanks SO much Hector! That worked perfectly -- I am *most* grateful to you. Cheers, -Alan On Nov 12, 4:14 pm, Hector Virgen [EMAIL PROTECTED] wrote: I think maybe something like this might work: $('.maps').click(function() { $(this).next('.expander.map').show(); }); That would expand the next map based on whatever was clicked. I hope this helps :) -Hector On Wed, Nov 12, 2008 at 12:04 PM, alanfluff [EMAIL PROTECTED]wrote: Yep. Get that. Tks. However, I am trying to make my code re-useable, right now there are two sets of trigger-and-map markup. I will have 10 to 20. I was hoping to find a jQ construct that would say: if a map-trigger is clicked, I will expand the map that immediately follows it in the DOM. That way I would not need to have an #id for each trigger/map in HTML and the jQ would be one lump of code, not a set of identical lumps, each one handling one of the trigger-and-maps. Thanks again for your reply - sorry if I'm not explaining myself well. Cheers, -Alan On Nov 12, 2:53 pm, Hector Virgen [EMAIL PROTECTED] wrote: You're right, $('.linkify.map:first') will always return the first element that matches linkify.map. If you want to make it in respect to a container, try $('#container').find('.linkify.map') -Hector On Wed, Nov 12, 2008 at 11:49 AM, alanfluff [EMAIL PROTECTED]wrote: Almost what I want - but the first map is always the one shown, I could have explained better, my bad, sorry. Pseudo code for what I have: . . click-to-trigger-map mapOne[div] . . click-to-trigger-map mapTwo[div] . . etc The :first seems to make mapOne display, regardless which click-to- trigger I click. It looks as if the scope of the :first is the whole DOM and no starting from the point where the click occurred and affecting the first instance after it (which is what I want). Thanks in advance for any further help! Cheers, -Alan On Nov 12, 2:36 pm, alanfluff [EMAIL PROTECTED] wrote: Thanks _lots_ for the quick reply Hector -- I'll go try that. Cheers! On Nov 12, 2:22 pm, Hector Virgen [EMAIL PROTECTED] wrote: Try $('.linkify.map:first'). That should return the first matched element. -Hector On Wed, Nov 12, 2008 at 11:04 AM, alanfluff [EMAIL PROTECTED]wrote: Hi, I am trying to limit the scope of a click trigger to the first/next matched target. This works fine if I have one container of class .expander.map but as soon as I add another, they both respond (I guessed they would ;) $('.linkify.map').click(function() { $('.expander.map').show(); }); I have tried using $(this) and .next() but likely not correctly... I am _certain_ this is stupidly simple and I am missing the obvious. Grateful if anyone can point me in the right direction. Cheers lots in advance! [I am a lightweight (little experience) when it comes to JavaScript/ jQuery, so much so that even though I have jQuery Ref and Learning books, I still have not sussed this. What am I like...]