Combine hover and click functions (jQuery)?

后端 未结 8 740
一整个雨季
一整个雨季 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:43
    var hoverAndClick = function() {
        // Your actions here
    } ;
    
    $("#target").hover( hoverAndClick ).click( hoverAndClick ) ;
    
    0 讨论(0)
  • 2020-12-04 09:44
    $("#target").hover(function(){
      $(this).click();
    }).click(function(){
      //common function
    });
    
    0 讨论(0)
提交回复
热议问题