jsCSS
Create a new CSS tag with yourName = new jsCSS();
. yourName
can be any variable name you like. You can create as many new jsCSS()
s as you need, and the ones you make last will take priority. To include this file, simply add the following to your page's <head>
tag:
<script src="jsCSS.min.js"></script>
Add rules with yourName.addRule(selector,rules)
, where selector
is a text string, a normal CSS selector. rules
is an object containing all the rules you would like to apply as {"key": "value"}
pairs.
Delete rules with yourName.deleteRule(selector,rules)
, where selector
is a text string, a normal CSS selector. rules
is an Array containing all the rules you would like to delete as strings.
My name's Xsanda, and I'd love it if you were to mention it if you use this tool!
Download
Example
var css = new jsCSS() css.addRule("p, a",{ "font-family": "'Segoe UI', Helvetica, Calibri, sans-serif" }).addRule("code, pre",{ "font-family": "'Ubuntu Mono', Monaco, monospace" }).addRule("h1, h3",{ "font-family": "'Segoe UI', Helvetica, Calibri, sans-serif", "text-decoration": "underline" }) var colouring = new jsCSS() colouring.addRule("span.string",{ "color": "red" }).addRule("span.maths",{ "color": "blue" }).addRule("span.var",{ "color": "purple" }).addRule("span.function",{ "color": "teal" }).addRule("span.selector",{ "color": "maroon" }).addRule("span.rule",{ "color": "fuchsia" })