Finding the id of a parent div using Jquery

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

I have some html like this:

Volume =

相关标签:
9条回答
  • 2020-11-29 17:42

    Try this:

    $("button").click(function () {
        $(this).parents("div:first").html(...);
    });
    
    0 讨论(0)
  • 2020-11-29 17:42
    $(this).parents('div').attr('id');
    
    0 讨论(0)
  • 2020-11-29 17:42

    This can be easily done by doing:

    $(this).closest('table').attr('id');
    

    You attach this to any object inside a table and it will return you the id of that table.

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