OZONE Asylum
Forums
DHTML/Javascript
stuck...again... working with jQuery
This page's ID:
31072
Search
QuickChanges
Forums
FAQ
Archives
Register
Edit Post
Who can edit a post?
The poster and administrators may edit a post. The poster can only edit it for a short while after the initial post.
Your User Name:
Your Password:
Login Options:
Remember Me On This Computer
Your Text:
Insert Slimies »
Insert UBB Code »
Close
Last Tag
|
All Tags
UBB Help
Hi guys :) Stuck on another javascript bit. Workign with jQuery, I have little snippet I wrote to show or hide various <div>'s when a checkbox is clicked, depending on whether or not the checkbox is checked. There are 5 categories of information being displayed in a table, and the idea is that the user can un-check a box to hide a category, and re-check the box to show the category. There is also a 'show all' checkbox that will show all of the div's (and a couple minor UI bits that check the boxes and disable the input based on the circumstances). The code I am using is as follows: [code] $("#cal-all").click(function(){ if($(this).attr("checked" == true)){ $("#cal-all").attr("disabled", "disabled"); $("#cal-head input:not(#cal-all)").attr("checked", "checked"); $("table.calendar div").show(); } }); $("#cal-head input:not(#cal-all)").click(function(){ var classMatch = $(this).attr("id"); if($(this).attr("checked" == false)){ $("div." + classMatch).hide(); $("#cal-all").attr("checked", ""); $("#cal-all").attr("disabled", ""); } else{ $("div." + classMatch).show(); } }); [/code] Everything works as I want it to except for the last part - the 'else'. When a box is unchecked, the corresponding div's are hidden (finds all divs with a class that matches that of the checkbox clicked). When I click the 'show all' checkbox, all div's are shown (just shows all of the divs in the table regardless of class). But when I check a checkbox that had been un-checked, the corresponding div's are [b]not[/b] shown (using the same method of matching the class as the hide). I posted this on the jQuery help forum, where I've had good luck in the past, and have had no replies. I thought I'd at least get "RTFM newb" or something ;) I am wondering if the hide() adds a class to the element? Do I need to isolate the class I am looking for in that case? Any tips appreciated! thanks :)
Loading...
Options:
Enable Slimies
Enable Linkwords
« Backwards
—
Onwards »