完美运行,是不是最简代码
<!--当点击相应按钮,执行相应操作,为按钮添加相应事件-->
<input type="button" value="改变颜色" onclick="colorchenge()" >
<input type="button" value="改变宽高" onclick="sizechenge()">
<input type="button" value="隐藏内容" onclick="hideelement()">
<input type="button" value="显示内容" onclick="nohideelement()">
<input type="button" value="取消设置" onclick="cancel()"> </form>
<script type="text/javascript">//定义"改变颜色"的函数
var text=document.getElementById("txt");
function colorchenge(){
text.style.color="red";
text.style.backgroundColor="#CCC"; }
//定义"改变宽高"的函数
function sizechenge(){
text.style.width="800px";
text.style.height="600px"; }
//定义"隐藏内容"的函数
function hideelement(){
text.style.display="none"; }
//定义"显示内容"的函数
function nohideelement(){
text.style.display="block"; }
//定义"取消设置"的函数
function cancel(){
if(cancel=true){
text.style="none"; }
else{ } }
</script></body></html>以上代码编辑后测试可运行相应要求,请各位大神看看是否为最简化的代码;
烦请指正和优化,欢迎讨论