DOMAssistant.CSS Module
The DOMAssistantCSS module offers various methods for adding and removing CSS classes, checking if an element has a certain class and getting the rendered style for a specific property on an element.
addClass(className)
Adds a class name to the current element, unless it already exists.
Parameters
- className
- Desired class name to be added. Required.
Return value
Element which called the method.
Example calls
$("container").addClass("selected");
removeClass(className)
Removes a class name from the current element.
Parameters
- className
- Desired class name to remove. Required.
Return value
Element which called the method.
Example calls
$("container").removeClass("selected");
hasClass(className)
Checks whether the current element has a certain class name.
Parameters
- className
- Class name to check if it exists on the current element. Required.
Return value
Boolean. Whether the element has the requested class or not.
Example calls
$("container").hasClass("selected");
getStyle(cssRule)
Gets the rendered style for a certain CSS property on the current element, no matter if it was applied inline or from an external stylesheet. Note: make sure to look for the specific property instead of general ones. I.e. background-color
instead of backgrund
etc.
Parameters
- cssRule
- CSS property to check value of. Use CSS syntax for the property, i.e.
background-color
instead ofbackgroundColor
. Required.
Return value
String. The value of the requested style.
Example calls
$("container").getStyle("background-color");
DOMAssistant.CSS methods
DOMAssistant modules
- DOMAssistant Core
- DOMAssistant.AJAX
- DOMAssistant.Content
- DOMAssistant.CSS
- DOMAssistant.Events
- DOMAssistant.Load
CSS selectors
Download DOMAssistant
All modules in one file
-
DOMAssistant 2.5.7, compressed
(22kb, 7kb Gzipped) - Intended for production usage.
-
DOMAssistant 2.5.7, complete
(43kb) - Intended for learning and development usage.