I am wanting to be able to select chunks of CSS Rules using JavaScript or jQuery and get them into a variable, basically as the preformatted text you would expect in a style-sheet.
Ideally we would carefully comment our CSS styles and have them simply in the <head> <style>
tag on the html page. The JavaScript would locate the particular comment that wraps the rules within the <style>
tag on the page, and copy those rules to a variable as text, for later use.
/* CSS Rules */
.example{
font-size: 1em;
color:blue;
}
/* end */
In this case the script would find the string /* CSS Rule */
, then select all the lines below it until it hits a terminating comment /* end */
Any ideas? I've googled a fair bit for a solution, but guess this is a pretty unusual thing to be doing, having a hard time finding any pointers.