Div onclick event not called in Mozilla

后端 未结 6 1109
予麋鹿
予麋鹿 2021-01-23 04:29

I have this in my code:

Title
6条回答
  •  暗喜
    暗喜 (楼主)
    2021-01-23 05:00

    I think, you can remove "onclick" from your html

    Title
    Other title

    And then try something like this

    $('#22').on('click', function (e) {
        your code
    });
    

    But if your div id="22" will be added dynamically your should use something like this

    $('parent').on('click', '#22', function (e) {
        your code
    });
    

    where 'parent' - static element already existed in document before click

提交回复
热议问题