Createinlinestyle:function() {//Create an inline style sheet varstyle = document.createelement (' style ');//Create a STYLE element varHead = Document.head | | document.getElementsByTagName (' head ') [0];//elementStyle.type = ' text/css ';//You must display the Type property of the style element as TEXT/CSS, otherwise it will not work in IEHead.appendchild (style);//Insert the created style element into the head returnstyle; }, Getinlinestyle:function() {//get an inline style sheet; search backwards varHead = Document.head | | document.getElementsByTagName (' head ') [0];//element varchildren=Head.children; varInlinestyle =NULL; for(vari = children.length-1; I >= 0; i--) { varnode =Children[i]; if(Node.tagname = = "STYLE" && node.type = = "Text/css") {Inlinestyle=node; Break; } } if(!inlinestyle) {//There is no inline style sheet createdInlinestyle = This. Createinlinestyle (); } returnInlinestyle; }, Addinlinecss:function(csstext) {varstyle = This. Getinlinestyle (); if(Style.stylesheet) {//IE varFunc =function () { Try{//prevents errors in IE from exceeding the limit of stylesheetStyle.styleSheet.cssText =Csstext; } Catch(e) {Console.log ("The number of stylesheet exceeds the limit!" "); } } //If the current stylesheet is not available, then the line is placed in async if(style.styleSheet.disabled) {setTimeout (func,10); } Else{func (); } } Else{// the //In the Web browser, just create a text node and insert it into the style element. varTextnode =document.createTextNode (csstext); Style.appendchild (Textnode); } }
Use:
var cssrowaltbackcolor = cssselect + "tr.datagrid-row-alt{background-color:" + Customstyle.rowaltbackcolor + "}";
Eai Addinlinecss (Cssrowaltbackcolor);
css--Creating CSS