Alex C Alex C - 1 year ago 185
Javascript Question

JQuery trigger hover won't work with :not(:hover)

I have a case very similar to this one:

I'm trying to use jquery mouseenter to trigger a hover on the first image which has Id one.

window.setTimeout(function () {
}, 2500)

However this doesn't appear to work, neither in my code nor in the one in the link above, as :not(:hover) style appears to always be applied. I've also tried with $().offset() to trigger redraw but that won't work either.

Answer Source

You could use a class to apply the hover styles (using opacity for example)

.image {
  opacity: .5;

.image:hover, {
  opacity: 1;

and then add it in your timeout (and make sure to cleanup the class on real hovers)

jQuery(function($) {
  function enter() {

  function leave() {

  $('.image').hover(enter, leave);

  setTimeout(function() {$('.image:first-child'));
  }, 2500);
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download