Combine hover and click functions (jQuery)?

后端 未结 8 758
一整个雨季
一整个雨季 2020-12-04 08:50

Can hover and click functions be combined into one, so for example:

click:

$(\'#target\').click(function() {
  // common operation
});
8条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-04 09:36

    You could also use bind:

    $('#myelement').bind('click hover', function yourCommonHandler (e) {
       // Your handler here
    });
    

提交回复
热议问题