---
title: "html按钮有两种 button,div显示,"
author: "chokee"
date: "2014-05-07T15:26:53Z"
tags: []
categories: ["Web前端"]
slug: "html-button-div"
draft: false
lastmod: "2016-01-05T16:45:52Z"
id: 2062697
url: "https://chokee.iteye.com/blog/2062697"
---

html按钮有两种：
<input type="button" value="登录" onclick="login()"/>
和<button onclick="login()">登录</button>
这两种在页面上看起来好像一样没什么区别，但是这两种是有区别的。
1，如果在<form id="loginForm" name="loginForm" action="<%=path%>/hdlogin/login.action" method="post"></form>
标签中，使用<input type="button" value="登录" onclick="login()"/>，要想提交form，
你必须写成<input type="submit" value="登录" onclick="login()"/>，
或者document.loginForm.submit();否则form是不会提交的。
2，如果在form中使用<button onclick="login()">登录</button>只要点击就会提交。
<button type="submit" value="登录" onclick="login()"/>。
今天在使用<button></button>时，我又在js控制表单提交，结果这个action总是莫名其妙的走两次！
根源就是表单提交了两次，一次是<button></button>，一次是document.loginForm.submit();
这个错误很隐蔽，大家以后要注意。
//////////////////////
<script>  
    $(function (){  
        $("#btn").linkbutton({  
            plain:false,  
            text:'xixihaha'  
        })  
          
        //点击禁用，完成禁用方法  
        $("#jin").click(function (){  
          <span style="color:darkred">  $("#btn").linkbutton('disable')  </span>
        })  
  
        //点击启用，完成启用方法  
        $("#qi").click(function (){  
<span style="color:darkred">            $("#btn").linkbutton('enable')  </span>
        })  
    })  
</script>  
        <a href="#" id="btn" iconCls="icon-search">easyui</a>    
        <a href="#" id="jin" class="easyui-linkbutton" >禁用</a>  
        <a href="#" id="qi" class="easyui-linkbutton">启用</a>  
        <!--  
        linkbutton的属性  
        id：分配给该组件的ID。  
        disabled：设置为true将禁用按钮。  
        plain：为true时不显示边框浮上去会显示边框，相反就是正常的样式，默认是false  
        text：按钮上显示的文字。  
        iconCls：用来在左边显示一个16x16大小图标的css类。  
  
        linkbutton的方法  
        disable：禁用按钮。  
        enable：启用按钮。  
        -->  


/////////////////////
$("#hide").click(function(){
  $("p").hide();
});

$("#show").click(function(){
  $("p").show();
});

 div的visibility可以控制div的显示和隐藏，但是隐藏后页面显示空白:
　　style="visibility: none;"
　　document.getElementById("typediv1").style.visibility="hidden";//隐藏
　　document.getElementById("typediv1").style.visibility="visible";//显示
 
　　通过设置display属性可以使div隐藏后释放占用的页面空间，如下
　　style="display: none;"
　　document.getElementById("typediv1").style.display="none";//隐藏
　　document.getElementById("typediv1").style.display="";//显

////////////////
刷新父页面
window.parent.location.reload();/