jQuery $.closest() (Or whichever comes first)
-
20-09-2019 - |
Question
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?
Solution
Have you tried:
$.closest("td, div")
?
OTHER TIPS
As an alternative to what cletus mentioned, what is wrong with simply:
$("#textareaId").parent()
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow