做了个实验:
<head runat="server">
<title></title>
<script>
</script>
</head>
<body>
<form id="form1" runat="server">
<div id="d1" style="width:100px; height:10px;"></div>
<input type="text" id="txt"/>
<input type="button" onclick="alert(d1.style.height);"/>
</form>
</body></html>这样的话,IE可以alert出元素高度,火狐不行.
然后把
<input type="button" onclick="alert(d1.style.height);"/>
改成
<input type="button" onclick="alert(txt.value);"/>
的话,两者都能显示输入框高度.是不是意味着对于输入表单,FF和IE都能直接通过ID访问,而对于非输入表单,FF必须通过getElementById访问,而IE依然可以直接通过ID访问呢?
请指教!~谢谢~~~
<head runat="server">
<title></title>
<script>
</script>
</head>
<body>
<form id="form1" runat="server">
<div id="d1" style="width:100px; height:10px;"></div>
<input type="text" id="txt"/>
<input type="button" onclick="alert(d1.style.height);"/>
</form>
</body></html>这样的话,IE可以alert出元素高度,火狐不行.
然后把
<input type="button" onclick="alert(d1.style.height);"/>
改成
<input type="button" onclick="alert(txt.value);"/>
的话,两者都能显示输入框高度.是不是意味着对于输入表单,FF和IE都能直接通过ID访问,而对于非输入表单,FF必须通过getElementById访问,而IE依然可以直接通过ID访问呢?
请指教!~谢谢~~~
FF不支持d1.style.....
就像谷歌代码 大小写一样
ajax的时候, 大小写出问题都不能运行,而且,谷歌直接屏蔽所有的js报错.
<input type="button" onclick="alert(d1.style.height);"/>
你这样直接写出来 浏览器不知道 你引号中是什么东东
<input type="button" onclick="javascript:alert(d1.style.height);"/>
这样子试试吧