Solved

jquery Show tree if a child is selected

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

Please see the following link:
Example

You will notice that I have commented out the jquery code that hides all the children.
You will also notice that Sub1->1 has been checked.

What I want to do is hide all the children (ie by uncommenting out the jquery)
and then have some jquery that looks at all the children.
If any are checked, then that parent (and all the parents before that) must be expanded.
In this example,

Main, all of Main's immediate children should be shown and Sub1's children should be shown.
Sub2 should be shown but it's children mustn't be shown as none are checked.

Please can you help me with this jquery?

Many Thanks!
0
Comment
Question by:jagku
2 Comments
 
LVL 82

Accepted Solution

by:
leakim971 earned 500 total points
ID: 36521872
test page : http://jsfiddle.net/5Xkkf/

$('ul[id^="sub_"]').not( $(":checked").parents('ul[id^="sub_"]') ).hide();
0
 

Author Closing Comment

by:jagku
ID: 36521887
Excellent - all makes sense.
Many Thanks as always!
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

jQuery is a JavaScript library that greatly simplifies JavaScript programming. AJAX is an acronym formed from "Asynchronous JavaScript and XML."  AJAX refers to any communication between client and server, when the human client does not observe a…
The Confluence of Individual Knowledge and the Collective Intelligence At this writing (summer 2013) the term API (http://dictionary.reference.com/browse/API?s=t) has made its way into the popular lexicon of the English language.  A few years ago, …
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

829 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