我的問題很簡單,如果DOM不會有一個文本框的值,其用戶類型怎樣的JavaScript檢測瀏覽器用戶鍵入的最新文本檢測在文本框中的文本,即使pagesource顯示文本框前值
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script type="text/javascript">
function showalert() {
var x = document.getElementById('<%=txtbx.ClientID %>').value;
alert(x);
return false;
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:TextBox ID="txtbx" runat="server" Text=""></asp:TextBox>
<input type="submit" onclick="return showalert();" value="OK" />
</div>
</form>
</body>
</html>
以上是我的代碼。 頁面源不顯示用戶在文本框中鍵入的最新文本。 該代碼在所有瀏覽器和所有VS版本中的工作方式類似。 我甚至跑一個普通的HTML頁面的代碼,而一個Visual Studio
我發佈了答案嘗試, – 2014-09-25 08:46:50