jquery closest dl element
Posted
by
Sebastiaan
on Stack Overflow
See other posts from Stack Overflow
or by Sebastiaan
Published on 2011-06-24T07:20:00Z
Indexed on
2011/06/24
8:23 UTC
Read the original article
Hit count: 245
HTML:
<dl id="feature-list">
<dt id="basic" class="category-name">
<dd id="basic-toggle" class="category-recepient">
<div class="feature">
<div class="feature-content">
<input id="checkbox1" type="checkbox">
</div>
</div>
</dd>
<dt id="options" class="category-name">
<dd id="options-toggle" class="category-recepient">
<div class="feature">
<div class="feature-content">
<input id="checkbox2" type="checkbox">
</div>
</div>
</dd>
</dl>
JQUERY
$('input').change(function () {
var value = $(this).closest("dt");
//do something with value.id
});
$(this).closest("dt")
returns the checkbox instead of <dt id="(category)" class="category-name">
I tried $(this).closest(.category-name)
, $(this).closest("dt").find(.category-name)
© Stack Overflow or respective owner