Events on dynamically added classes

前端 未结 4 1934
逝去的感伤
逝去的感伤 2021-01-27 11:39

I have a form where the class of the button is dynamically changing, depending up where the request is coming from. I am trying to capture the onclick event, but it does not tak

4条回答
  •  再見小時候
    2021-01-27 12:07

    I fixed the problem using the delegate method provided by JQuery.

    $('body').delegate('.newClass','click', delegatefunction);
    
    function hasClass() {
       alert("Hello!!");
    }
    

    Thanks for the help.

提交回复
热议问题