How to get the closest element id attribute

后端 未结 1 2013
借酒劲吻你
借酒劲吻你 2021-01-27 07:32

I am trying to find the closest element that has id attribute and get the id. The element could be

,

or other elements.

I

1条回答
  •  隐瞒了意图╮
    2021-01-27 07:54

    You can get rid of the div entirely and look for all elements that have an id attribute:

    $('#test').closest('[id]').attr('id');
    

    0 讨论(0)
提交回复
热议问题