我把动态添加的按钮的value属性的值设置为"保存修改",可是按钮上面什么都没有,这是怎么回事??
<%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*" errorPage="" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
<script>
function addButton(){
      NewButton=document.createElement("button");
  NewButton.id="button2";
  NewButton.style.display="";
  NewButton.style.width="180px"; 
  NewButton.style.height="120px";
  NewButton.value="保存修改";//就是这个value的值"保存修改"没有在按钮上面显示出来。如何才能让它显示出来??
  document.getElementById("body").appendChild(NewButton);
}
</script>
</head>
<body id="body">
  <input type="submit" name="Submit" value="添加按钮" onclick="addButton()" />
</body>
</html>

解决方案 »

  1.   

    补充:是在Firefox中看不到,而在IE中就没问题。
      

  2.   

    修改一下, OK了<script> 
    function addButton(){ 
      NewButton=document.createElement("input"); 
      NewButton.type="button";  

      NewButton.id="button2"; 
      NewButton.style.display=""; 
      NewButton.style.width="180px"; 
      NewButton.style.height="120px"; 
      NewButton.value="保存修改";//就是这个value的值"保存修改"没有在按钮上面显示出来。如何才能让它显示出来?? 
      document.getElementById("body").appendChild(NewButton); 

    </script> 
      

  3.   

    <script> 
    function addButton(){ 
      NewButton=document.createElement("input"); 
      NewButton.id="button2"; 

      NewButton.type="button";
      NewButton.style.display=""; 
      NewButton.style.width="180px"; 
      NewButton.style.height="120px"; 
      NewButton.value="保存修改";//就是这个value的值"保存修改"没有在按钮上面显示出来。如何才能让它显示出来?? 
      document.getElementById("body").appendChild(NewButton); 

    </script> 
      

  4.   

    <script> 
    function addButton(){ 
      NewButton=document.createElement("input"); 
      NewButton.id="button2"; 
      NewButton.type="button"; 
      NewButton.style.display=""; 
      NewButton.style.width="180px"; 
      NewButton.style.height="120px"; 
      NewButton.value="保存修改";//就是这个value的值"保存修改"没有在按钮上面显示出来。如何才能让它显示出来?? 
      document.getElementById("body").appendChild(NewButton); 

    </script> 
    浏览器是有差异的啊,建议使用IE7啊
      

  5.   

    借上面的,再多说一句:button和type为button的input不是一种元素。