I am trying to find out what div is the span is in using jquery.
here is a eg.
<div id='one'></div>
<div id='two'></div>
<div id='three'><span id="find_me"></span></div>
thanks
I am trying to find out what div is the span is in using jquery.
here is a eg.
<div id='one'></div>
<div id='two'></div>
<div id='three'><span id="find_me"></span></div>
thanks
This will get the id of the <div>
parent of the <span>
with the id find_me
:
$("#find_me").parents("div").attr("id")
Use .closest()
to find the closest ancestor div
(.parent()
will only find it it if the div is the immediate parent).
$('#find_me').closest('div').attr('id')