How to get parent element by specified tag name using jquery? How to get parent element by specified tag name using jquery? jquery jquery

How to get parent element by specified tag name using jquery?


See .closest():

Get the first ancestor element that matches the selector, beginning at the current element and progressing up through the DOM tree.

I.e.,

$('#myId').closest('table')

(Demo)


$('#myId').closest("table");


$('#myId').parents('table') works as well