[jQuery] Problem with toggles and if statements
Hi there, please have a look at http://clients.larsschulz.info/cc104_web/panel/quicklinks.html I have h3 elements that are followed by divs that are toggled when the h3 element is clicked... //quicklinks - slide up and down on click $(h3.trigger).click(function(){ $(this).next(.sectiontext).slideToggle(150); }); Now I want to have certain divs visible when I load the page: //quicklinks - activate div $(h3.active).next(.sectiontext).slideToggle(fast); I have the problem that the later misbehave, when I toggle them. The action is actually reversed... (click the example Test 1 post several times to see what I mean. Can anybody help with this? Thank you so much Cheers Lars PS: I tried the following code as a starting point: //quicklinks - switch the Open and Close state per click if($(h3.trigger).hasClass(active)) { $(h3.trigger).toggle(function(){ $(this).addClass(active); }, function () { $(this).removeClass(active); }); } else { $(h3.trigger).toggle(function(){ $(this).removeClass(active); }, function() { $(this).addClass(active); }); }
[jQuery] Re: Modifying CSS classes with jQuery (or '.live()' for '.css')
What I have is a number of divs, belonging to several categories. These divs come and go. The color of a div should be determined by the color defined for the category they belong to; category colors change as well. Say we're dealing with just a single category, colored red. One div might be present: div class=cat_1/ We use the command you used to set the color to red $('.cat_1').css ('color', '#ff'); With this method, when another div belonging to the same category is added, the command will have to be called again. Or a div changes category, which can happen, the command will have to be called again. The problem is that the .css() function merely sets the style attribute of every element matched. Instead would like to change the stylesheet definition for '.cat_1', requiring only one call (when a category color is set). On Mar 30, 8:32 pm, James james.gp@gmail.com wrote: Documentation:http://docs.jquery.com/CSS $(#myElem).css('color', '#ff'); It would probably be better if 'cat_[id]' is the element's ID rather than a CLASS, provided that it's unique in the whole document: div id=cat_12.../div Using that, you can easily update a whole set of 'cat_[id]' in one call (if that's what you want to do): $([id^=cat_]).css('color', '#ff'); This will update every element with IDs that begin with 'cat_'. Theoretically you can do that with CLASS also, but when the CLASS attribute also allows definition of multipleclasses, such as: class=header cat_45 in which case would require a bit more work to locate because it would not fall in the criteria of begins with cat_ anymore. On Mar 29, 4:23 am, Lars Schöning tahp...@gmail.com wrote: Hello, Apologies if this turns out to be a trivial question. I currently am working withjQueryon a set of elements assigned to colored categories via a 'cat_[id]' class. Categories can change colors and if they do I want to update the color of every elements belonging to it. I want the same to be true in all new events added. I would believe that the easiest solution to this problem would be changing the 'color' attribute directly in theCSSclass 'cat_[id]', but have found no way to do so. As I am fairly new tojQueryI might also be overseeing a much more elegant solution. Can anyone clarify? Thanks in advance, Lars
[jQuery] Modifying CSS classes with jQuery (or '.live()' for '.css')
Hello, Apologies if this turns out to be a trivial question. I currently am working with jQuery on a set of elements assigned to colored categories via a 'cat_[id]' class. Categories can change colors and if they do I want to update the color of every elements belonging to it. I want the same to be true in all new events added. I would believe that the easiest solution to this problem would be changing the 'color' attribute directly in the CSS class 'cat_[id]', but have found no way to do so. As I am fairly new to jQuery I might also be overseeing a much more elegant solution. Can anyone clarify? Thanks in advance, Lars
[jQuery] Change background of table row based on column's value
I am totally new to jQuery. I wonder if it's possible to change the background color of any row in the table below where the value of the table cell belonging to class numericColumn is greater than 90? The values in this column will always be numeric. Thanks for any help, Lars table class=importResults tbody tr td0/td td class=numericColumn66/td tdNo significant changes/td /tr tr td491/td td class=numericColumn1/td tdFailed DPV because of invalid primary/td /tr /tbody /table
[jQuery] quick note about cross domain getScript function
Hi, A note about 1.3; I still need to do this http://groups.google.com/group/jquery-en/msg/996ace3956f70102 to get $.getScript or $.ajax to call the `complete' callback when `dataType' is script and I'm doing cross-domain requests. (i cba. registering at a bug-tracker)
[jQuery] Patch to make ajaxStop event fire on cross-domain/subdomain use of getScript/ajax
Hey, I couldn't get the ajaxStop global event to fire on errors (connection dropped etc.) when doing cross-domain/subdomain calls to getScript/ajax without doing this: --- old-symbolicweb/javascript/jquery-1.2.6.js 2008-07-18 13:38:02.0 +0200 +++ new-symbolicweb/javascript/jquery-1.2.6.js 2008-07-18 13:38:02.0 +0200 @@ -2668,7 +2668,7 @@ var done = false; // Attach handlers for all browsers - script.onload = script.onreadystatechange = function(){ + script.onerror = script.onload = script.onreadystatechange = function(){ if ( !done (!this.readyState || this.readyState == loaded || this.readyState == complete) ) { done = true; ..only tested on IE6 and FF2.x for now. I'm not sure it is correct in general but this works for me now. -- Lars Rune Nøstdal http://nostdal.org/