SoFunction
Updated on 2025-03-03

JavaScript new style rules (recommended)

The key code is as follows:

<html>
<head>
<link rel="stylesheet" type="text/css" href="">
<script>
=function(){
 var sheet=[0];
 //【New style rules】// ('.div1{font-size:16px;color:red;}',0); IE8 and above do not support //The first parameter is the style, and the second is the position of the style  // ('.div1','font-size:20px;color:orange;font-weight:bold;',0);//IE all support //The first parameter is the style name, the second style position is the style rule, and the third is the style position. function insertCss(element,csName,position){//Cross-browser compatibility if(){ // When it is not IE, a function will be read, and when it is above IE8, undefined will be read(element+'{'+csName+'}',position);
}else if(){
(element,csName,position);
}
}
insertCss('.div1','font-size:16px;color:orange',0);
 //【Delete style rules】//(position); //Delete style Parameter is position //IE8 and above are not supported//(position); //Delete style Parameter is position//IE supportfunction deleteCss(position){//Cross-browser compatibilityif(){
 (position);
}else if(){
(position);
}
deleteCss(0);
}

}
</script>
</head>
<body></body>
</html>

The above is the new JavaScript style rules (recommended) introduced by the editor to you. I hope it will be helpful to you. If you have any questions, please leave me a message and the editor will reply to you in time. Thank you very much for your support for my website!