What I thought would be an easy one for .closest()
to handle turned out not to be (or perhaps I am making a silly mistake).
What I am trying to do is access the <label>
element from the <div>
with the inner text: I AM HERE
:
<li>
<label>I WANT TO ACCESS THIS ELEMENT</label>
<div>...</div>
<div>
<input/>
<input/>
<input/>
<div id="start">I AM HERE</div>
</div>
</li>
My first guess would have been to try this:
$('#start').closest('label')
But it does not return anything.
.closest()
doesn't seem to work right why not look at the.closest()
doco? Or the list of traversal methods: api.jquery.com/category/traversing/tree-traversal to find a more appropriate method... – Benavidez