Bug Tracker

Opened 11 years ago

Closed 9 years ago

#4636 closed feature (wontfix)

Another next function. either: $().nextOf() or $().verynext(sel)

Reported by: ericbojo Owned by: john
Priority: low Milestone: 1.4
Component: selector Version: 1.3.2
Keywords: traverse, next, nextOf, veryNext Cc:
Blocked by: Blocking:

Description

I think a good next function would be one that can find the Very next element that matches the selector.. For example: $("input[checkbox]").veryNext("input[checkbox]") would find only One elment that is the very next checkbox, either a Next sibling OR a descendent of a next sibling.

I think this is what people like me assume .next(sel) does, but it does not. Also Note that the "component" drop down below does not have a "traversing" item.

Why is this function needed? If I have a table of checkboxes, With the first column checkbox "enabling" the next column, it would be easier to implement with this function since the checkboxes are nested inside <tr><td> tags.

Change History (2)

comment:1 Changed 11 years ago by ericbojo

My selectors are written wrong, I mean: $(this).veryNext("[input=checkbox]"). (this being the currently selected Checkbox: which Could also be nested) Also the "veryNext" thing would Not need to be A direct next sibling, it should go to the next element and its children and so on until it finds a match or the end of the document and return null if nothing is found.

An example of the DOM where this might be used:

<table> <tr><td><input type="checkbox" onclick=" $(this).veryNext("[input=checkbox]").attr("disabled","");"/> </td><td><input type="checkbox"></td></tr> <table>

Basically, checking the first checkbox would enable the 2nd checkbox.. Ignoring my obvious logical/synatax errors.

comment:2 Changed 9 years ago by Rick Waldron

Priority: minorlow
Resolution: wontfix
Status: newclosed

$('foo').next() does this.

http://jsfiddle.net/rwaldron/WmLhE/

Note: See TracTickets for help on using tickets.