jquery use of bind vs on click

前端 未结 3 969
無奈伤痛
無奈伤痛 2020-12-02 12:54

I have come across several methods for handling click events in jquery:

bind:

$(\'#mydiv\').bind(\'click\', function() {
    ...
});
<
3条回答
  •  借酒劲吻你
    2020-12-02 13:44

    I think that you should have searched the jquery docs before posting this question :

    As of jQuery 1.7, the .on() method is the preferred method for attaching event handlers to a document.

提交回复
热议问题