jquery closest dl element
- by Sebastiaan
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)