Here is an option:
var style = document.createElement('style');
style.type="text/css";
style.innerHTML = '.cssClass { color: #F00; }';
document.getElementsByTagName('head')[0].appendChild(style);
document.getElementById('someElementId').className="cssClass";
More Related Contents:
- How to get an HTML element’s style values in javascript?
- Is it possible to alter a CSS stylesheet using JavaScript? (NOT the style of an object, but the stylesheet itself)
- Is there an easy way to reload css without reloading the page?
- Access CSS file contents via JavaScript
- Can jQuery change css style definition? (not individual css of each element)
- jQuery equivalent of YUI StyleSheet Utility?
- Get Element StyleSheet Style in JavaScript
- How to do this mouse over effect in jquery?
- How to change the style of alert box?
- Determine if an HTML element’s content overflows
- How do I simulate a hover with a touch in touch enabled browsers?
- Change link color of the current page with CSS
- Is there a way to make text unselectable on an HTML page? [duplicate]
- How can I let a table’s body scroll but keep its head fixed in place?
- Parsing CSS in JavaScript / jQuery
- Determine if an element has a CSS class with jQuery
- Why write when the mime type is set by the server?
- Show loading image while $.ajax is performed
- How to select all checkboxes with jQuery?
- How to convert unordered list into nicely styled dropdown using jquery?
- Responsive horizontal page sliding
- Need to find height of hidden div on page (set to display:none)
- change background image in body
- CSS fade left to right
- What are some good ways to prevent people from copying my source code? [closed]
- using css modules how do I define more than one style name
- IIS 7.5 no images css js showing
- How do I dynamically adjust css stylesheet based on browser width?
- Polymer share styles across elements
- How do I put a clear button inside my HTML text input box like the iPhone does?