Finding the id of a parent div using Jquery

前端 未结 9 1098
失恋的感觉
失恋的感觉 2020-11-29 17:00

I have some html like this:

Volume =

9条回答
  •  孤街浪徒
    2020-11-29 17:41

    You could use event delegation on the parent div. Or use the closest method to find the parent of the button.

    The easiest of the two is probably the closest.

    var id = $("button").closest("div").prop("id");
    

提交回复
热议问题