改变 HTML 样式
如需改变 HTML 元素的样式,请使用这个语法:
document.getElementById(id).style.property=new style
<p id=\"p2\">Hello World!</p>
<script>
document.getElementById(\"p2\").style.color=\"blue\";
</script>
JS改变元素属性;
<script>
var div = document.getElementByIdx_x(\'d1\');
div.setAttribute(\"class\", \"abc\");
</script>
本文地址:https://www.stayed.cn/item/8360
转载请注明出处。
本站部分内容来源于网络,如侵犯到您的权益,请 联系我