JQuery click event only works after moving the mouse in Chrome

So, I know there are better ways to switch styles, but carry me ...

There seems to be a small bug in Chrome (but not Firefox) where the 'click' event will not do anything until the mouse moves after the event.

$(function(){ $('#selectsomething a[rel$=".css"]').click(function(e){ e.preventDefault(); $('link.skeletor').attr('href', $(this).attr('rel')); }); }); 

So, if you click the link, but don’t move the mouse, nothing happens ... Do you think this could be a legitimate error with Chrome or am I something wrong?

+6
source share
1 answer

I do not understand why this should not work (except for the strange rel = "" use).

If you are trying to use a mini version or a version with multiple js instances, the problem may be to use .click instead of .on('click', function(e)) .

To see an example of what I'm trying to say, check out my script.

To fully explain the differences between the two click functions, this overflow

-1
source

Source: https://habr.com/ru/post/987520/


All Articles