Alexander Hein Alexander Hein - 3 months ago 8
jQuery Question

How can I run this function on hover?

How can I run this function on hover?

$cellButtonGroup.on( 'click', '.button', function() {
var index = $(this).index();
$carousel.flickity( 'select', index );
});


This did not work:

$cellButtonGroup.on( 'hover',

Answer

try this

$cellButtonGroup.hover(function() {
  //your code here
});

or else you can use mouseenter and mouseleave insted of above with following ways.

1st way

$cellButtonGroup.mouseenter(function() {
      //your code here
    });

$cellButtonGroup.mouseleve(function() {
      //revise your code here [ex: if your add some class in mouseenter, remove that in here]
    });

2nd way

    $cellButtonGroup.mouseenter(function(){
      $("your selector").addClass("thisIsanExample", function(){
      $("you selector").removeClass("thisIsanExample");
    })

});