lb.base.dom.css

DOM (Document Object Model) CSS (Cascading Style Sheets) Adapter Module for Base Library

Authors

Copyright

Eric Bréchemier © 2011, Some Rights Reserved Legal-Box SAS © 2010-2011, All Rights Reserved

License

BSD License http://creativecommons.org/licenses/BSD/

Version

2011-08-14

Summary
lb.base.dom.cssDOM (Document Object Model) CSS (Cascading Style Sheets) Adapter Module for Base Library
Functions
getClasses(element): objectGet a hash of classes found on given DOM element.
addClass(element, name)Append a CSS class to the className of a DOM element.
removeClass(element, name)Remove a CSS class from the className of a DOM element.

Functions

getClasses(element): object

Get a hash of classes found on given DOM element.

Parameters

elementDOM Element, an element node (with or without a class atribute)

Returns

object, a hash object with properties named after the classes found, e.g.

{'big':true, 'box':true}

for

<div class='big box'></div>.

When no class attribute is present, or when it is empty, an empty object is returned.

addClass(element, name)

Append a CSS class to the className of a DOM element.

Parameters

elementDOM Element, an element (with or without a class attribute)
namestring, the name of a new CSS class to append to existing ones

Note

Nothing happens in case a class with the same name is already present.

removeClass(element, name)

Remove a CSS class from the className of a DOM element.

Parameters

elementDOM Element, an element (with or without a class attribute)
namestring, the name of a CSS class to remove from existing ones

Note

Nothing happens in case no class with this name is present.

Close