Element extensions

June 3, 2012

After cleaning up some JS in metromaze, I added a few extensions on the DOM object element that I thought could be something other people would be interested in as well. I use the functions for the toggling of the comment field.

These functions are good for the following browsers, IE8-9, Chrome, Firefox, Safari, Opera.

There’s four functions I’ve added to all elements within the DOM tree;

  • add_event; Crossbrowser eventlistener
  • toggle_class; Crossbrowser css class toggler
  • add_class; Crossbrowser css class adder
  • remove_class; Crossbrowser css class remover

Download the extension with an example

View the example

Tags