The funny thing is, I can't remember the syntax for any of this stuff. I literally go to http://jquery.com/api every time I want a click function.
The important thing is to remember what is possible. Just the core alone is so powerful. Then add the plugins and it's virtually unlimited. If jQuery saves you time and money, consider a donation to the project. :) Glen On 8/7/07, dug <[EMAIL PROTECTED]> wrote: > > > Glen, > > When I started trying to do this with jquery this morning I tried > using toggle but instead got bogged down trying to make is work as > part of an 'animate' hash... > > Your solution works beautifully! Thanks very much :-) > > Ben, I'd been putting alerts in to try and figure out why my if > statement wasn't working. Strangely, if you assign a string "#abc" to > the css property using the .css() construct, when you print out the > result with an alert it gets converted to "rgb(1,2,3)" which is odd > but I'm sure there's an explanation... > > Of course this is all moot if the lovely toggle thingie does all the > legwork for you:-) > > Thanks for you help :-) > Dug > > > On Aug 7, 3:24 pm, "Glen Lipka" <[EMAIL PROTECTED]> wrote: > > You may want to check out the Toggle function. It might eliminate the > need > > for the IF. > > Maybe even the toggleClass() method? http://www.jquery.com/api > > > > $(".doSetSelect").toggle(function(){ > > $(this).parents(".def_set").addClass("selected");},function(){ > > > > $(this).parents(".def_set").removeClass("selected"); > > > > }); > > > > Of course you don't need to use the css class, but it's sometimes easier > > that way, especially if you have several rules on it. > > > > I didnt follow the part you said about display block, but you can do the > > following: > > $(this).parents(".def_set:visible").addClass("selected"); > > :visible means "Only find the ones that are not not display:none." > > > > Glen > > > > On 8/7/07, dug <[EMAIL PROTECTED]> wrote: > > > > > > > > > Dear all, > > > > > I've been faffing with this thing all morning. The more I faff, the > > > closer I get to using getElementById. The following should toggle the > > > background colour of a submit button's parent (a containing 'span' tag > > > pair set to display:block) > > > > > I am obviously missing something very simple. > > > > > $(".doSetSelect").click(function(event) { > > > > > if ($(this).parents(".def_set").css("backgroundColor") == > > > "rgb(238,238,238)") > > > { $(this).parents(".def_set").css({backgroundColor: > > > "rgb(255,255,255)"}) } > > > else > > > { $(this).parents(".def_set").css({backgroundColor: > > > "rgb(238,238,238)"}) } > > > > > return false; > > > }); > > > > > In expectation of kicking myself ;-) > > > > > All the best, > > > Dug > >