Events on dynamically added classes

前端 未结 4 1973
逝去的感伤
逝去的感伤 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:01

    Thats cause when you bind the click event the element has another class.

    Try somesthing like this:

    $('body').on('click', '.newClass', function () {
            alert('test');
        });
    

    Example

提交回复
热议问题