Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jQuery $.closest() (Or whichever comes first)

While working a project tonight, I ended up using one .js resource file for two different pages. One page contains a textarea within a div, and another contains a textarea within a td. Wanting to work with the siblings of this textarea, and other children of its parent, I wondered how you could best implement "closest div or td, whichever comes first" logic via jQuery syntax.

What are your guys' suggestions?

like image 929
Sampson Avatar asked Aug 31 '09 00:08

Sampson


1 Answers

Have you tried:

$.closest("td, div")

?

like image 196
cletus Avatar answered Sep 19 '22 07:09

cletus



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!