I’m having some strange issues with .removeClass() and .addClass() in jQuery.
Specifically it seems that when I use .removeClass() the class is indeed removed, but a single space is left in it’s place. then when I .addClass("secondclass") I get class=" secondclass" (with the space in front).
I’m using jQuery 1.4.1
Is this intended behaviour or a bug? How to stop it?
UPDATE:
Some people have asked what problems this is causing. Well, I’m using thins:
$("img.someclass").click(function() {
I’m testing this with Firefox 3.6.3
Which does not trigger with the space in front of the class name. When I manually remove the space it works fine. It seems that there is more too this problem than the space issue, and most likely the space wasn’t causing any issues (glad it’s gone though 😉 – Will post seperate question regarding the ongoing issue.
this is the bug in jQuery version 1.4.1, but this is fixed in jQuery version 1.4.2. If you want to stop this behavior, you can use the latest version.