首页 > Web开发 > 详细

HTML <button>标签

时间:2016-11-22 17:55:09      阅读:281      评论:0      收藏:0      [点我收藏+]

如果<button>标签在<form>中不加type=“button”,那么默认含义是“submit”。

<button>标签里面disabled属性使其不可用,常见javascript修改disabled属性实例:(a键b键互相撕逼)

<style>
  #a,#b
  {
  height:30px;
  width:70px;
  background:yellow;
  box-sizing:border-box;
  }

  
  
  
  </style>
 </head>
 <body>
 <button type="button" id="a" onclick="an()" >会变色</button>
 <button type="button" id="b" onclick="bn()" >会变色</button>
	<script>

	function bn()
	{

		if(document.getElementById("b").disabled!="true")

		{
			document.getElementById("b").disabled="true";
			document.getElementById("b").style.background="gray";
			document.getElementById("a").removeAttribute("disabled");
			document.getElementById("a").removeAttribute("style");
		}
		else
		{
			document.getElementById("a").disabled="true";
			document.getElementById("a").style.background="gray";
			document.getElementById("b").removeAttribute("disabled");
			document.getElementById("b").removeAttribute("style");
		}

	}
	function an()

	{

		if(document.getElementById("a").disabled!="true")
		{
			document.getElementById("a").disabled="true";
			document.getElementById("a").style.background="gray";
			document.getElementById("b").removeAttribute("disabled");
			document.getElementById("b").removeAttribute("style");
		}
		else
		{
			document.getElementById("b").disabled="true";
			document.getElementById("b").style.background="gray";
			document.getElementById("a").removeAttribute("disabled");
			document.getElementById("a").removeAttribute("style");
		}
	}
	</script>
</body>

  

 

HTML <button>标签

原文:http://www.cnblogs.com/GUOZHENY/p/6085955.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!