var a=document.getElementById("con"); a.style.color="red"; a.style.backgroundColor="#ccc"
请问为什么这里
var a=document.getElementById("con").innerHTML;
不能实现改变颜色和背景颜色呢??
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
innerHTML问题?求大神解释?-PHP中文网问答-innerHTML问题?求大神解释?-PHP中文网问答
围观一下哦,学习一下。
第二个获取的是id为con的标签里的内容,而背景色和颜色是标签的属性,不是标签里的内容的属性