Solved

jquery Show tree if a child is selected

Posted on 2011-09-12
2
587 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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

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…
OverviewThis article demonstrates a simple search form using AJAX. The purpose of the article is to demonstrate how to use the same code to render a page and javascript (JQuery) and AJAX to make subsequent calls to refine the results. The princip…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

746 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now