下面,先來段簡單的測試代碼
<!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" lang="zh-CN">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>不要被悶了</title>
<body>
<input type="text" id="hh1" value="2">
<input type="hidden" id="hh2" value="2">
<input type="text" style="display:none" id="hh3" value="2">
<div style="display:none"><input type="text" id="hh4" value="2"></div>
<script>
document.getElementById("hh1").value="11111";
document.getElementById("hh2").value="11111";
document.getElementById("hh3").value="11111";
document.getElementById("hh4").value="11111";
var strall="h1="+document.getElementById("hh1").value;
strall+=",h2="+document.getElementById("hh2").value;
strall+=",h3="+document.getElementById("hh3").value;
strall+=",h4="+document.getElementById("hh4").value;
alert(strall);
</script>
</body>
</html>
接着上三張在IE、火狐、Chrome瀏覽器調試工具顯示的源代碼中結果圖
******************************IE開發人員工具顯示的源代碼***************************************
******************************Firebug工具顯示的源代碼***************************************
******************************chrome開發人員工具顯示的源代碼***************************************
其上代碼執行結果都是一樣的,如下圖:以後不要被悶到了!如果是開發工具顯示設置問題,或者編寫什麼兼容代碼等,還望留言,感謝感謝!