Solved

Select/Deselect all in a <ul> 'tree' structure

Posted on 2011-09-09
2
346 Views
Last Modified: 2012-05-12
Hello Experts,

Please see the following link for my progress so far:

Example

(To be honest, I have had to delete the jquery as I simply can't get it to work!)

I am trying to achieve the following:

When a user clicks on the Select all box, I want ALL the children (including any grandchildren etc) to be ticked. Likewise, if the user then untick the box, it should do the opposite.

Many thanks for any help!
0
Comment
Question by:jagku
2 Comments
 
LVL 82

Accepted Solution

by:
leakim971 earned 500 total points
ID: 36510225
try : http://jsfiddle.net/ZzTZP/

$(":checkbox", "li:contains('Select All')").click(function() {
    $(this).closest("ul").find(":checkbox").attr("checked", $(this).is(":checked") );
})

Open in new window


you may create/set a class for each checkbox "Select All" and use :

"li.selectAllClass" instead  "li:contains('Select All')"
0
 

Author Closing Comment

by:jagku
ID: 36510306
Many Thanks.
As suggested, I added <li class="selectAll">
and changed the

$(":checkbox", "li:contains('Select All')").click(function() {

to

$(":checkbox", "li.selectAll").click(function() {
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

ASP.NET AJAX callbacks to web service are becoming very popular and unavoidable these days. The feel that the user gets when only a part of the page is updated without even hindering the UI is the advantage that the callbacks offer. The wait for the…
Introduction HyperText Transfer Protocol (http://www.ietf.org/rfc/rfc2616.txt) or "HTTP" is the underpinning of internet communication.  As a teacher of web development I have heard many questions, mostly from my younger students who have come to t…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

685 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question