简体   繁体   中英

Can't trigger hover event on other element with jQuery

Hello I am trying to write a jQuery snippet which will simulate a hover event on flipbox when a button is clicked. The main problem is that I have tried all solutions given on stackoverflow for this scenario but it just doesn't seem to work at all.

Front of flipbox in dev console

Front of flipbox in dev console

Below are the code I have tried on this same element

jQuery('.eael-elements-flip-box-container').mouseenter().mouseleave();
jQuery('.eael-elements-flip-box-container').mouseover();
jQuery('.eael-elements-flip-box-container').trigger("hover");
jQuery('.eael-elements-flip-box-container').trigger("mouseover");
jQuery('.eael-elements-flip-box-container').trigger("mouseenter");

You could trigger the event and have an event listener on the other element like this:

$("#click-btn").click(()=>{
   $(".hover-me").trigger('mouseover')
})

$(".hover-me").mouseover(()=>{
  console.log('hovered')
})

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM