Allow just one click in class JQUERY

后端 未结 2 488
日久生厌
日久生厌 2020-12-12 01:03

I have a link that will load via ajax some content.

My problem is, I don\'t want to remove the text \"Load comments\", I just want to not allow more clicks in this c

2条回答
  •  猫巷女王i
    2020-12-12 01:45

    Use jQuery's one() function

    $(".showcomments").one("click", function() {
    

    http://www.w3schools.com/jquery/event_one.asp

    The one() method attaches one or more event handlers for the selected elements, and specifies a function to run when the event occurs.

    When using the one() method, the event handler function is only run ONCE for each element.

提交回复
热议问题