Reputation: 169
i have html elements
<ul> <li> <dl class="details clear"> <dt>TIME : </dt> <dd>09:00:00-10:00:00</dd> <dt>Availible Days : </dt> <dd>monday,tuesday,wednesday</dd> <dt></dt> <dd> <label class="edit-details white_blue" style="float:right;margin-right:10px;">EDIT</label> <label class="delete-details white_red" style="float:right;margin-right:10px;">DELETE</label> </dd> </dl> <dl class="details clear"> <dt>TIME : </dt> <dd>10:30:00-11:30:00</dd> <dt>Availible Days : </dt> <dd>monday,tuesday,wednesday</dd> <dt></dt> <dd> <label class="edit-details white_blue" style="float:right;margin-right:10px;">EDIT</label> <label class="delete-details white_red" style="float:right;margin-right:10px;">DELETE</label> </dd> </dl> </li> </ul>
i want to get the index of edit label, if it is in the first "dl" must alert 0 else if it is in the second "dl" must alert 1
So far i did
$("label").click(function () {
var parent_el = $(this).parents('li');
alert(parent_el.index(this));
});
Please help
Upvotes: 0
Views: 198
Reputation:
$("label").click(function () {
var parent_el = $(this).parents('dl');
alert($("dl").index(parent_el));
});
OR
$("label").click(function () {
var parent_el = $(this).parents('dl');
alert(parent_el.index());
});
Upvotes: 1