标签:return fun asc ret click style == doc dom
<style>
#p1 {
color: red;
}
</style>
</head>
<body>
<button onclick="myFunction()">点击</button>
<p id="p1" >我在这里改变了样式</p>
<script>
function myFunction () {
var sum =document.getElementById("p1");
if (sum.style.color == "red" || sum.style.color == "" )
{
return sum.style.color = "skyblue";
}else {
return sum.style.color = "red";
}
}
</script>
</body>
使用JavaScript来选择性改变HTML DOM中元素的样式,使用if语句。
标签:return fun asc ret click style == doc dom
原文地址:https://www.cnblogs.com/whrgm/p/9460118.html