Combine hover and click functions (jQuery)?

后端 未结 8 774
一整个雨季
一整个雨季 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:44

    $("#target").hover(function(){
      $(this).click();
    }).click(function(){
      //common function
    });
    

提交回复
热议问题