I have to traverse up until element have id attribute. My problem here is element is not definite and sometimes parent have id attribute, sometimes grandparent have id attribute like that goes on. I try like
var id = $(this).closest().find("['id']").attr("id");
i dont have such ideas to do this . Can anyone help me
Try using the
[id]selector string inside the.closest, so thatclosestreturns the element with an ID. Note that the selector string shouldn't have"s around theid: