<!--当点击相应按钮,执行相应操作,为按钮添加相应事件--> <input type="button" value="改变颜色" onclick="changecolor()"> <input type="button" value="改变宽高" onclick="changewidth()"> <input type="button" value="隐藏内容" onclick="hidetext()"> <input type="button" value="显示内容" onclick="showtext()"> <input type="button" value="取消设置" onclick="setfirst()"> </form> <script type="text/javascript"> var mychar=document.getElementById("txt"); function changecolor(){ mychar.style.color="red"; mychar.style.backgroundColor="#fcc"; } //定义"改变颜色"的函数 function changewidth(){ mychar.style.height="600px"; mychar.style.width="800px"; }//定义"改变宽高"的函数 function hidetext(){ mychar.style.dispaly="none"; }//定义"隐藏内容"的函数 function showtext(){ mychar.style.dispaly="block"; }//定义"显示内容"的函数 function setfirst(){ var message=confirm("你确定要重置所有设置么?"); if(message==true){ txt.removeAttribute('style'); } }//定义"取消设置"的函数
添加回答
举报
0/150
提交
取消