jQuery - how to determine which link was clicked

前端 未结 4 1209
一向
一向 2021-01-23 18:34

I have a simple piece of PHP which generates n copies of the following code:

4条回答
  •  闹比i
    闹比i (楼主)
    2021-01-23 19:09

    Add the complete URL to your link (or p in this case) using a data attribute:

    Click Here to See Data

    Then do all the binding directly in your jQuery so you have direct access to the link that was clicked:

    $(document).ready(function() {
        $('.ShowSDB_L2').on('click', function(e) {
            e.preventDefault();
            $('.divSDB_L2').empty().load($(this).data('loadurl')).show();
        });
    });
    

提交回复
热议问题