![]() |
Decision Tree / Drill Down
Hello all, I have been working on a drill down menu / decision tree for a bit here with jQuery. I had an easy nice setup done, but it doesn't work the way I'd like it to 100%.
In any case. I am trying to just step through a list. For example: HTML Code:
<h3>Is the Sky Blue?</h3>I have been trying, with jQuery something like this: Code:
$('h3').click(function(){Code:
$('h3').click(function(){ |
You're attaching your event handler to the H3 element, when the click should be occuring on one of the two LI elements in your parent unordered list, no?
javascript Code:
Add an element id to the parent UL and try something like the above. |
Thanks
Yes, that is what I need to do just about. I have multiple nested UL, about 7 deep, so your solution set me in the right direction.
I ended up doing this: Code:
$(document).ready(function() {Thanks again.:-P |
Code:
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>I have tried some things such as .next().hide(), replaceWith(), etc... but I cannot get it working. I was thinking Siblings() would be the choice, but that failed right away... |
You're probably going to want to check out the .parent() and .siblings() methods, though I'm sure there are many ways to accomplish your goal. If you set up multiple divs, uls, or other elements that you wish to use, you might also benefit from something like .replaceWith(), depending on how you wish to go about the process; for a quick and dirty example, see http://pastebin.com/NHEM10s2
|
Hum, you beat me to the punch while I was writing your example up. I think you're on the right path though, as we both thought of the same methods. I would keep trying, jQuery is pretty intuitive with such operations once you get the first attempt working.
|
| All times are GMT. The time now is 05:14 PM. |
Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0