MetaGuru
MetaGuru

Reputation: 43843

Is there a way to reference a different child element of the same parent element of $(this) in jQuery?

So if I had an input element in a certain div and another input element in that same div, is there a way I could reference that second input element from a $(this) that came from a change event of the first input element? This way I could have an infinite number of possible divs but each change would only effect the second element of that is sharing the div with the first element (which called the change event)?

Upvotes: 0

Views: 97

Answers (2)

middus
middus

Reputation: 9121

As I've told you in my answer to your other recent question, you are looking for ways to traverse the DOM. You can find the documentation on the functions mentioned by John over here.

Upvotes: 0

John Rasch
John Rasch

Reputation: 63445

$(this).next('input')

or if it's before:

$(this).prev('input')

or if you're not sure:

$(this).siblings('input')

Upvotes: 4

Related Questions