为何我的只有先是隐藏有用,其他的都没反映
<form>
<!--当点击相应按钮,执行相应操作,为按钮添加相应事件-->
<input type="button" onclick="secai()" value="改变颜色" />
<input type="button" value="改变宽高" onclick="weight()"/>
<input type="button" onclick="hidetext()" value="隐藏内容" />
<input type="button" onclick="showtext()" value="显示内容" />
<input type="button" onclick="changeRemove()" value="取消设置" />
</form>
<script type="text/javascript">
function secai()
{
var myyanse=document.getElementById("txt").style.color="red";
}
function weight()
{
var kuangao=document.getElementById("txt");
kuangao.style.width=300px;
kuangao.style.height=200px;
}
function hidetext()
{
var b=document.getElementById("txt").style.display="none";
}
function showtext()
{
var b=document.getElementById("txt").style.display="block";
}
function changeRemove()
{
var txt= document.getElementById("txt");
var changeRemove=confirm("确认要恢复初始样式吗?"); if(changeRemove==true)
{
txt.removeAttribute("style");
}
}
</script>
</body>
</html>