1.1cssText``(``给文本设置样式``)
//语法element.style.cssText=attr
<div id="test">hello world</div>
<script>
var test = document.getElementById("test");
test.onclick = function(){
this.style.cssText="border:1px solid #333;color:red";
}
</script>
1.2length``(``弹出提示框样式属性有几种``)
<div id="test" style="color:red;font-size: 18px">hello world</div>
<script>
var test = document.getElementById("test");
test.onclick = function(){
alert(this.style.length)
}
</script>
1.3getPropertyValue``(``弹出提示框显示文本颜色``)
<div id="test" style="color:red;font-size: 18px">hello world</div>
<script>
var test = document.getElementById("test");
test.onclick = function(){
alert(this.style.getPropertyValue("color"))
console.log(this.style.color)
}
</script>
1.4item(弹出提示框显示文本样式的属性名)
方法接受一个整数值作为参数,返回该位置的 CSS 属性名
<div id="test" style="color:red;font-size: 18px">hello world</div>
<script>
var test = document.getElementById("test");
test.onclick = function(){
alert(this.style.item(0)) //color
}
</script>
1.5removeProperty(点击样式消失)
接受一个属性名作为参数,在 CSS 规则里面移除这个属性
<div id="test" style="color:red;font-size: 18px">hello world</div>
<script>
var test = document.getElementById("test");
test.onclick = function(){
this.style.removeProperty("color")
}
</script>
1.6setProperty()
//语法
setProperty(attr,value)
