document.getElementById(id).style.display="none";为隐藏
//document.getElementById("test1").style.display="block";//显示
document.getElementById(id).style.display="";为显示
代码实例
<table width="100%" class="resbutton"> <tr> <td align="left" width="33%"> <input type="button" name="DataMaintenance" class="button" value="新增" οnclick="add()" id="news"/> <input type="button" name="DataMaintenance" class="button" value="修改" οnclick="modify()" id="test1" /> </td> </tr> </table> <script Language="Javascript1.2"> if(table1.rows.length==0){ //alert("aaa"); document.getElementById("test1").style.display="none";//隐藏
document.getElementById("test1").style.display="";//显示
}else{ //alert("bbb"); document.getElementById("news").style.display="none"; }
</script>