I am trying to find the closest element that has id attribute and get the id. The element could be , or other elements. I 相关标签:
id
, or other elements. I 相关标签:
,
I
You can get rid of the div entirely and look for all elements that have an id attribute:
div
$('#test').closest('[id]').attr('id');