Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/35.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何通过JavaScript在属性之前应用css?_Javascript_Css_Selector - Fatal编程技术网

如何通过JavaScript在属性之前应用css?

如何通过JavaScript在属性之前应用css?,javascript,css,selector,Javascript,Css,Selector,如何通过javascript应用此代码?如果要使用js添加样式,可以使用style.sheet的insertRule(),示例代码: var表=(函数(){ //创建标记 var style=document.createElement(“样式”); //网络工具包黑客:( style.appendChild(document.createTextNode(“”); //将元素添加到页面中 document.head.appendChild(样式); 返回样式表; })(); //考试 she

如何通过javascript应用此代码?

如果要使用js添加样式,可以使用style.sheet的
insertRule()
,示例代码:

var表=(函数(){
//创建标记
var style=document.createElement(“样式”);
//网络工具包黑客:(
style.appendChild(document.createTextNode(“”);
//将元素添加到页面中
document.head.appendChild(样式);
返回样式表;
})();
//考试
sheet.insertRule(“主体{背景色:红色;}”,sheet.length);
//对于您的代码,只需替换param

//sheet.insertRule(“input.star:checked~label.star:before{content:'\f005';color:#FD4;transition:all.25s;}}}}”,sheet.length);
如果您想用js添加样式,可以使用style.sheet的
insertRule()
,示例代码:

var表=(函数(){
//创建标记
var style=document.createElement(“样式”);
//网络工具包黑客:(
style.appendChild(document.createTextNode(“”);
//将元素添加到页面中
document.head.appendChild(样式);
返回样式表;
})();
//考试
sheet.insertRule(“主体{背景色:红色;}”,sheet.length);
//对于您的代码,只需替换param

/Studio.Engult/Studio(“输入:StAR:Cuth~标签”:St:{内容:‘f00’5’;颜色:A.FD4;过渡:所有.25s;},“片长”);您是否考虑使用jQuery?jQuery不会使这比使用jQuery时所考虑的简单JavaScript更简单吗?jQuery不会使这比普通JavaScript更简单。
`   input.star:checked ~ label.star:before {
            content: '\f005';
            color: #FD4;
            transition: all .25s;
        }    `