-1
所以我试图改变一个盒子的背景,但我明白了。 请我需要你而不是我已阅读的所有答案,他们中的任何一个都不能解决我的问题。 我就是因为我是编程的新手。 这是代码:Uncaught TypeError:无法读取属性'样式'null
<button onclick="changeBG('box1','#F0F');">Magenta</button>
<div id="box1"> content in box1</div>
<style type="text/css">
div#box1{
background-color: #9dceff;
width:400px;
height:200px;
}
</style>
<script type="text/javascript">
function changeBG(el,color){
var elem = document.getElementById('el');
elem.style.transition ="background 1.0s linear 0s ";
elem.style.background =color;
}
</script>
预先感谢您
非常感谢你的配合,你的回答非常有用。上帝保佑你 – Ferdinand 2014-11-06 07:52:56