我在获取asp服务器元素
数据时遇到问题。
这是我的用户代码文本框
。
以及我想要的脚本得到它的值(value)。但它不起作用。
请帮助我。
提前谢谢。
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
<div>
<asp:TextBox ID="txtUserCode" runat="server" Width="78%" Height="35%"></asp:TextBox>
</div>
</asp:Content>
<script type="text/javascript">
$(document).ready(function ()
{
$("input[type='text']").change(function ()
{
var textBox = document.getElementById('<%= txtUserCode.ClientID %>');
alert(textBox);
});
});
</script>
最佳答案
使用alert(textBox.value);
代替alert(textBox)
关于javascript - 在 javascript 中获取 asp 服务器元素时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14478695/