Back to Top

Fixed Remove class issue with MooTools

RemoveClass issue with Mootools

Yesterday I was working with one functionality of MooTools.One issue happened with me so I am sharing that issue and solution with you.

I was using a MooTools and had an issue in one of the Element Method removeClass() of MooTools and the surprise part is, there was no error in the Error console. The part of the code where I used addclass() element was working fine but only the removeclass() method was not working within my code.As I have tried by replacing removeClass() method with another method and it was working fine.

removeclass() element method removes the class from the Element.

SYNTAX:

className: a class name you want to remove from an element.

Let’s see my code as follows:

Mootools Script:

HTML Code:

In Above Mootools Script only “removeClass()” method was not worked and, first of all, I was not getting what was the issue and I tried a lot with this issue and then have made a quick search and found the answer for the same.

Finally, I got that the removeClass() method is working fine with simple class value like “class field” but it’s not working with class value validate[‘required’] which contain square bracket because the MooTools removeClass() method bottlenecks the class name into the middle of a regex and its create problem to escape embedded regex metacharacters within a class.

However, The solution for the above issue is to apply \ with remove class value like validate\[‘required’\] and the problem was resolved, the remove class method was working fine after that.That’s it.

Here, See Mootools script which was working fine after adding value like “validate\[‘required’\]”.

Also Read:

Lazy Load Plugin for jQuery Explained
To Call Remote URL in $.ajax method in jQuery
jQuery Shake Effect Explained

Don’t forget to subscribe to our free Email updates :). Do you have any question in above explanation or have you ever faced such issue, let me know via comment.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Most Popular Posts

How to call Remote URL in jQuery Ajax?

Posted on 11 years ago

Bhumi

How to use JavaScript Promise API?

Posted on 7 years ago

Bhumi

Static Methods and Properties in PHP

Posted on 12 years ago

Bhumi