7

So I know there are better ways of switching styles, but bear with me...

There seems to be a small bug happening on Chrome (but not Firefox) where the 'click' event wont do anything until the mouse has moved 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 may be a legitimate bug with Chrome or am I doing something wrong?

AndrewL64
  • 15,794
  • 8
  • 47
  • 79
  • 8
    I can't fathom why this got five upvotes. I also can't reproduce your problem. Can you create a stack snippet or jsFiddle that shows the problem? Here's mine that works fine in Chrome without having to move the mouse http://jsfiddle.net/j08691/e6k2zzsc/ – j08691 May 19 '15 at 19:45
  • 1
    As a side note, an anchor tag with a `rel` attribute containing a value ending with `.css` is invalid. According to [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a#attr-rel): _"...this attribute specifies the relationship of the target object to the link object. The value is a comma-separated list of link types values..."_ A list of valid link types can be found [here](https://developer.mozilla.org/en-US/docs/Web/HTML/Link_types). – War10ck May 19 '15 at 19:57

1 Answers1

0

I don't why this shouldn't work (except the strange rel="" use).

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

To see an example of what i trying to say, check out my Fiddle.

For a full explanation on the difference between the two click functions check this overflow

Community
  • 1
  • 1
Jelle Verzijden
  • 325
  • 3
  • 11