Questions tagged [jquery-traversing]

Functions in the Traversing category in the jQuery JavaScript library allow for the selection and manipulation of element(s) based on the function description.

A complete list of supported traversal functions is available at jQuery's API documentation: Traversing. Subcategories of this category are Filtering, Tree Traversal, and Miscellaneous Traversal.

Functions like .children(), .prevAll() and .each() are included in this category.

162 questions
18
votes
7 answers

jQuery nextUntil, including, not excluding the matched element?

Is there a way to easily do nextUntil, so that the element matched by the selector is included? I have this, which is only fine if there is a previous sibling: $("#content").find("h3:first").prev().nextUntil("ul:last").wrapAll("
jwinn
  • 1,135
  • 3
  • 14
  • 30
16
votes
1 answer

How to get all parents until a certain parent is reached

I need something in-between the functionality of .closest() and .parents(). I am applying some CSS to all parents of a certain element up to a certain parent. Right now I'm while looping up, but it seems like there is a better way to do this. var…
brentonstrine
  • 21,694
  • 25
  • 74
  • 120
13
votes
5 answers

Is there a jQuery selector to accomplish this task?

I have these 4 HTML snippets: Siblings:
...
...
...
Wrapped 1:
...
...
Eric
  • 95,302
  • 53
  • 242
  • 374
11
votes
2 answers

jQuery get id of element by searching for it by class

This is my html :
a
b
I want to get the ID of the parent div("#my_box_one") using the class of that…
DMin
  • 10,049
  • 10
  • 45
  • 65
11
votes
5 answers

jQuery - Count list children not containing div with class

I have a simple js script that counts the number of children an unordered list has. I'm trying to change the script so it doesn't count any children (li) which contain a div with the class 'hiddenItem'. Here's the list and the js.
BD_Design
  • 269
  • 5
  • 13
8
votes
3 answers

Traverse up until some element

I have some element selected with jQuery selector. It is en element from list of elements with the same class ('my-elements'). Now I'd like to select element containing the selected one which is several levels above. How can I do this ?
marks34
  • 1,997
  • 3
  • 16
  • 13
8
votes
4 answers

How can I filter data returned from jQuery?

jQuery code: $(document).ready(function() { $('#s-results').load('get_report1.php').show(); $('#search-btn').click(function(){ showValues(); }); $(function() { $('form').bind('submit', function() { showValues(); return false; }); }); …
Ankit Sharma
  • 398
  • 1
  • 7
  • 19
8
votes
5 answers

Best method to select an object from another unknown jQuery object

Lets say I have a jQuery object/collection stored in a variable named obj, which should contain a DOM element with an id named target. I don't know in advance if target will be a child in obj, i.e.: obj = $('
8
votes
3 answers

Select and disable each input field within a form, wrapped in a table in jquery

I am disabling a form based on a checkbox... I am having trouble adding the disabled attribute. here is what I got so far: HTML: …
Derek Adair
  • 21,846
  • 31
  • 97
  • 134
7
votes
1 answer

jQuery chaining parent(), is there an easier way?

Hay, I have some markup like this and some jQuery like this $(this).parent().parent().attr("id") $(this) is referring to the 'a' tag within the 'h2' Is there an easier way to select the…
dotty
  • 40,405
  • 66
  • 150
  • 195
7
votes
3 answers

jQuery - check if selected row is last visible row in table

previously i checked whether a row is last row in a table like this in a condition: $row.is(':last-child') which works fine. Now, i have a requirement where some of the rows in the table are hidden - now i have to check whether a specific row is…
owsata
  • 1,105
  • 1
  • 11
  • 24
6
votes
8 answers

Skip recursion in jQuery.find() for a selector?

TL;DR: How do I get an action like find(), but block traversal (not full stop, just skip) for a certain selector? ANSWERS: $(Any).find(Selector).not( $(Any).find(Mask).find(Selector) ) There were many truly great answers, I wish I could some how…
5
votes
2 answers

Traversing a table column -jQuery

Given a 3 by 3 table, i want to add a class to all the cells of 3rd column . I have tried doing $( 'td:eq(3)' ).addclass('special'); $( 'td:eq(5)' ).addclass('special'); $( 'td:eq(8)' ).addclass('special'); but the problem is writing 3 lines of…
HalfWebDev
  • 7,022
  • 12
  • 65
  • 103
5
votes
3 answers

Use jQuery's end() in my plugins

How can I copy the stack of a jQuery object to another jQuery object, so I can use end in my plugins even when returning totally unrelated objects? Example: $(myselector) .next() // Destructive operation .doSomething() …
mgibsonbr
  • 21,755
  • 7
  • 70
  • 112
5
votes
3 answers

JQuery-equivalent to prototypes Down()-function

I'm porting a webapp from prototype to jquery in which I often used the prototype Down() function. (selecting the first child of a given element) Glancing over the JQuery-api one of the ways to do this would be: prototype: $('abc').down(); jquery:…
Geert-Jan
  • 18,623
  • 16
  • 75
  • 137
1
2 3
10 11
Name: