
这段Javsscript代码为什么会产生“Microsoft JScript 运行时错误: 'null' 为空或不是对象”异常?
以下是ASP.NET的前端代码:<asp:TextBoxID="TextBox1"runat="server"Text=""></asp:TextBox><scripti...
以下是 ASP.NET的前端代码:
<asp:TextBox ID="TextBox1" runat="server" Text =""></asp:TextBox>
<script id="scr1" type ="text/javascript" >
function getValue() {
var x = document.getElementById("Text1");
alert (x.getAttribute("Text"))
}
</script>
<input id="Button1" type="button" value="button" onclick ="getValue()" />
单击 “Buttion1”时,希望得到 Text1的内容。 展开
<asp:TextBox ID="TextBox1" runat="server" Text =""></asp:TextBox>
<script id="scr1" type ="text/javascript" >
function getValue() {
var x = document.getElementById("Text1");
alert (x.getAttribute("Text"))
}
</script>
<input id="Button1" type="button" value="button" onclick ="getValue()" />
单击 “Buttion1”时,希望得到 Text1的内容。 展开
展开全部
貌似ID不是Text1吧?而是TextBox1。所以
var x = document.getElementById("TextBox1");
var x = document.getElementById("TextBox1");
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询