Combine hover and click functions (jQuery)?

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

    Use mouseover instead hover.

    $('#target').on('click mouseover', function () {
        // Do something for both
    });
    

提交回复
热议问题