</div>
<form>
<!--当点击相应按钮,执行相应操作,为按钮添加相应事件-->
<input type="button" value="改变颜色" ondick="set.changecolor()">
<input type="button" value="改变宽高"ondick="set.changewh()" >
<input type="button" value="隐藏内容" ondick="set.none()">
<input type="button" value="显示内容"ondick="set.block()" >
<input type="button" value="取消设置"ondick="set.quxiao()" >
</form>
<script type="text/javascript">
//定义"改变颜色"的函数
var txt=document.getElementById("txt");
var set={
chengecolor:function(){
txt.style.backgroundcolor="red";
txt.style.color="blue";
},
changewh:function(){
txt.style.width="500px";
txt.style.height="300px";
},
none:function(){
txt.style.display="none";
},
block:function(){
txt.style.display="block";
},
quxiao:function(){
var xiaoxi=confirm("确定要取消设置嘛?");
if(xiaoxi==true){
txt.removeAttribute('style');
}
}
}
没有结整标签啊</script>,还有ondick写错了吧应该有是onClick
<form>
<!--当点击相应按钮,执行相应操作,为按钮添加相应事件-->
<input type="button" value="改变颜色" onClick="set.changecolor()">
<input type="button" value="改变宽高"onClick="set.changewh()" >
<input type="button" value="隐藏内容" onClick="set.none()">
<input type="button" value="显示内容"onClick="set.block()" >
<input type="button" value="取消设置"onClick="set.quxiao()" >
</form>
<script type="text/javascript">
//定义"改变颜色"的函数
var txt=document.getElementById("txt");
var set={
changecolor:function(){
txt.style.backgroundColor="red";
txt.style.color="blue";
},
changewh:function(){
txt.style.width="500px";
txt.style.height="300px";
},
none:function(){
txt.style.display="none";
},
block:function(){
txt.style.display="block";
},
quxiao:function(){
var xiaoxi=confirm("确定要取消设置嘛?");
if(xiaoxi==true){
txt.removeAttribute('style');
}
}
}
</script>
</body>
确实呢,居然写成ondick。这错误真明显
onClick 写错了