JQuery :: Nested UL - Selecting Children One At A Time
Aug 9, 2011
So I'm new to jquery and I'm trying to spice up a navigation menu in my cms. I'm having trouble selecting children in a nested UL. Its just an add class on hover. But as you can see, it's selecting all of the children on hover. [URL]. I'm trying to find a solution that allows each listed link to be highlighted on hover, regardless of its place.
View 4 Replies
ADVERTISEMENT
Oct 30, 2009
I have a set of nested ULs that is generated for me. I want to use it to create a drop-down navigation menu, however I don't want to use the values in the second level of ULs in the navigation. It looks something like this:
<ul class="topMenu">
<li>home</li>
<li>community
[code]....
Level one is visible as sort of tabs, and then mousing over should reveal a list of the next level of links.I would like to use the above list and mouse over "community" and see a list of links
award type 1
award type 2
discussion 1
[code]....
Or another option would be to combine levels 2 and 3 so I would see
awards
award type 1
award type 2
discussions
discussion1
and then mousing over discussion 1 would reveal the more info link.
View 2 Replies
View Related
Feb 13, 2010
Given the following markup
<div id="menu">
<ul>
<li><a id="home" href="#">Home</a></li>
<li>
<a id="about" href="#">About</a>
<div>
About sub menu
</div></li><li>
<a id="products" href="#">Products</a>
<div><h2>Books</h2>
<ul><li>ColdFusion</li>
<li>jQuery</li>
<li>CSS</li>
<li>HTML</li>
<li>Groovy</li>
<li>Hibernate</li> .....
How can I grab only the 1st level children of my node? I want direct decendents of menu only. My code below is grabbing all <li> which is going to be a problem.
(function($){
$.fn.extend({
myplugin: function(options){
return this.each(function(){
// the object we are working with
var obj = $(this);
// get a list of menu items
var menuItems = $('li',obj);
});
}});
})(jQuery);
View 2 Replies
View Related
Feb 12, 2010
Taking the following markup
<div id="menu">
<ul>
<li><a id="home" href="#">Home</a></li>
<li>
<a id="about" href="#">About</a>
<div>
About sub menu
</div>
</li>
<li>
<a id="products" href="#">Products</a>
<div>
<h2>Books</h2> .....
How can I grab the immediate li children only and not all of the li that fall in this object. The following gives me every single <li> which is not what I am looking for.
(function($){
$.fn.extend({
myplugin: function(options){
return this.each(function(){
// the object we are working with
var obj = $(this);
// get a list of menu items
var menuItems = $('li',obj);
});
}});
})(jQuery);
View 2 Replies
View Related
Apr 21, 2010
I have the following scenario(well the structure is the same):
<fieldset id="fs"><p><select id="sl" runat="server" /></p></fieldset>
The name of the fieldset is constant but the name of the select is generated via asp.net thus i do not know the final id on that element. I can call on the select by using $("[id$='sl']").change() which works. But its a bad solution because I need to be sure that I only trigger the element under the fieldset "fs".
$("#fs").children().change()
Works as well but i obviously I am looking for a way to target only that select element under only that fieldset.
View 2 Replies
View Related
Aug 17, 2011
i'm trying to do the following: select the links one after another and add a class to them. When the next one is selected i want to remove the class from the previous.
[Code]...
View 4 Replies
View Related
Apr 27, 2011
I'm trying to select a class (.home) and an ID (#something) at the same time,
normally I'd use:
$(".home,#something")
but in this instance, the ID is already stored in a variable called "newpage" - I'm trying the following:
$(newpage,".home")
(note, selecting the id on it's own with just$(newpage) does work, so I know the issue isn't with my variable, it's just a matter getting both the class and the variable stored ID selected at the same time)
View 2 Replies
View Related
Jun 27, 2009
i want to get the ids of all the children of id 'top' and store it in an array in the order listed above. so final output in this case would be:
arr[0] = 1
arr[1] = 2
arr[2] = 3
is there a function or simple procedure that help me do this?
View 1 Replies
View Related
Dec 16, 2010
I have a div containing many children all very different, each one as a different width. I need to get the width of all the children. I mean child1.width() + child2.width() + child3.width() etc... Of course as a new child can be added anytime I can not use the kind of things I put above.
I tried that among other things :
$("div.mydiv").children().width();
But I only get the width ofthe first child.
View 2 Replies
View Related
Oct 7, 2010
I have about 13 ul li a items in a list and some have nested lists within them e.g. ul li ul li a and some don't. I want to prevent the default action on only a elements that have nested lists within them but not prevent default action for ones that don't. Here's an example of the markup.
[Code]...
However, instead, is there a way to tell jQuery to only apply this preventDefault to ul li a elements that have ul li a descendants/children (not sure of correct terminology here) so I can have the list items in any order?
View 3 Replies
View Related
Nov 26, 2010
just wondering if there is any way for the :contains to not look in children to find something? Tried $(':contains("$")');, but it returns everything. Was thinking of something like $(":not(':parent')").filter(':contains("$")');, but the console returns null (and even then it would exclude elements that have children and their text includes "$".)
Trying to make a script that looks through a page and finds the price on any page. The only way I could think of doing this relatively accurately is to search for all elements with "$" in the text, then get the one that has the largest height/width (That's problem #2, I think -- will deal with it once i get there :)
View 3 Replies
View Related
Jul 9, 2009
I'm trying to get an unordered list and its children as an HTML string on a mouseout event, but html()only selects the child elements:var theHtml = $('ul', this).html();I've tried using andSelf(), but that doesn't return the result I want:var theHtml =$('ul',this).and Self(). html();I can't choose $(this).html() as I need only the list.
View 2 Replies
View Related
Oct 28, 2010
I have:
<dt><a href="javascript:void(0);">Menu 1</a>
<dd>
<....>
[code]....
View 1 Replies
View Related
Nov 27, 2009
I'm a beginner at using jQuery for website interaction and I needed to create a simple sidebar menu. Here is the HTML code:
Code HTML4Strict:
<ul id="sidenav">
<li><a href="#">2010</a>
<ul>
<li><a href="#">January</a></li>
<li><a href="#">February</a></li>
[Code]...
It basically works, but only if I remove the code part where I first hide the children of the sidenav, but doesn't work when I want at default all children of the sidenav to be hidden and showed only if clicked a particular parent menu. 1. How can this be accomplished? 2. Also how can I hide the children of previous clicked parents when I click on another parent to chow it's children?
View 2 Replies
View Related
May 25, 2010
I am trying to assign a variable to a jquery object that is found using the children() and eq() methods. This is a simplified version of the html structure.[code]Here is the jquery code. All I want to do is assign an object to the variable and be able to manipulate the object through the variable. [code]Again this is a simplified version of my code but the structure is similar.
View 2 Replies
View Related
May 8, 2009
I have the following html and I'm trying to figure out how to delete the last rows the are children of div feed. I only want to leave a max of the first x rows. First I count them using $numdivs = $("#feed > div").size() - 1;. Then, I'm a bit lost on what to do next and have looked at the docs for children and thought of trying to traverse but can't seem to get it to work.
<body>
<div id="search">
</div>
<div id="feed">
<h2>Feed</h2>
<div id="firstrow" class="row"/>
<div id="1741946459" class="row">Test data for the first row</div>
<div id="1741946327" class="row">Test data for the second row</div>
<div id="1741939928" class="row">Test data for the blah row</div>
<div id="1741939928" class="row">Test data for the blah2 row</div>
<div id="1741939928" class="row">Test data for the blah3 row</div>
</div>
</body>
View 1 Replies
View Related
Dec 8, 2010
When calling remove on a selector, I understand that events & data are removed from the matched elements. What about children of these nodes, is the same true?
View 1 Replies
View Related
Jan 3, 2012
How to find grand children in a page
View 2 Replies
View Related
Mar 8, 2011
I'm building a volunteer translation site. In order to constantly update only paragraphs that multiple translators are working on, I need to pass an array to PHP of A: which paragraphs are open, and B: which translations have been submitted and are visible on the user's screen. PHP will then compare this with what is in the database and tell jQuery to add new submitted translation paragraphs or remove deleted ones.I've managed to make a string of all the open Div's and have it updated every second, like this:
function cycle(){
var data = '';
$('.paragraphtobetranslated:visible').each(function(){
[code]....
View 2 Replies
View Related
May 3, 2010
I need to select the last children of parent elements
For example
<ul>
<li></li> <-This will have the background #1a
<li></li> <-This will have the background #1a
<li><ul>
[Code]....
So I would need the last children. If there is no nested element then that is considered the last child. I have to write a jquery script to apply a background to the last children. A nested element can have a nested element and then that element's children will be considered the last ones so they will get the background but not the parents of those children. If the item has no children then that item will have a background.
So there are 3 different backgrounds. Each letter a, b c will represent a lighter tone compared to the previous color. C is lighter than B, B is lighter than A etc. So this will have to be a "smart" system in which the ul li will be updated and depending if it is the last one inhierarchyit will not have the arrow.
View 5 Replies
View Related
Oct 27, 2009
I'm trying to do a simple show/hide. When a user clicks an a link, I want to hide the dd for that link. Any ideas why the .children() is not working?
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
View 3 Replies
View Related
Jun 23, 2009
I got this here: [URL]. When you hover over the Buy Rhoadanide or Research the sub menu comes up. The only way I could get it to work was to make the OTHER menu hide if one is hovered over, but I cant hide them anymore
Is there a way to do this:
1. Hover Link
2. Show Div with more links below it
3. Keep the Divs visible if the Hover Link or the Div is hovered
4. Hide the Divs when both are not selected.
View 10 Replies
View Related
Sep 13, 2010
I have a UL that loads in dynamically after the DOM has already finished loading via and external API that doesn't have a callback function for when it's finished. However, I need to manipulate the children of the UL once it's loaded in, so I need some type of listener for when the UL changes.I need an event to fire when an element or it's children change.Is there anything like this in jQuery? Otherwise I'm going to have to create a setInterval to polloccasionallyto see if the UL has loaded, and that sounds sloppy.
View 3 Replies
View Related
Mar 18, 2011
I have the code:
console.log($(this).parent().parent().children());
console.log($(this).parent().parent().size());
And the output is:
jQuery(td.center, td.center, td.center, td.center, td.center, td, td) 1
Why is the size() 1 and not 7?
View 2 Replies
View Related
Feb 18, 2011
I have a button and a table that I want to clone when "Add new" button is pressed, and then append the cloned elements to the "items" container, but with updated id's and names - the update is done by appending the value of "num" attribute of "items". In the end I'll have to clone and update the id's and names for multiple input elements in the table found in the "default_container" - but right now it doesn't work even for direct children. The problem (one of them at least) right now is that the iteration over the children isn't performed.
$
(
document
).
ready
[Code].....
View 1 Replies
View Related
Jul 27, 2010
I'm trying to manipulate items in a table using jQuery, using the parent() and children() methods of the "this" object. I think I'm not understanding how to use the parent and children methods correctly.
What I want the code to do is to show the list and button within the <td></td> when clicked on, and then hide it when the newly shown button appears.
[Code]...
View 5 Replies
View Related