0

I'd like to add an attribute to a CSS class using MooTools. I know that I can use removeClass and addClass to add and remove classes from different elements, but I'm looking to modify the global behavior of the entire class itself.

The only thing I can think of is doing $$('.classname').each and using set('style','whatever'). Is there a better way?

1 Answer 1

2

yes - there is a better way, you can redefine the CSS style itself, else you'd have to continuously apply changes every time you create a new element of that class and that's not very performant and practical.

check this answer: Changing style of :hover selector in mootools and the jsfiddle i made for it: http://jsfiddle.net/dimitar/Z9RPP/

Sign up to request clarification or add additional context in comments.

2 Comments

oh yea Dimitar, +1, I thought 'a better way' in the sense of 'code syntax' :)
Very interesting approach. I wish there was a magic way to do it that didn't write a new <style> element, but I guess I do need to work in reality! Thanks! :D

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.