如何在 aspx 页面中使用 jquery/JavaScript 函数将焦点设置在放置在用户控件内的 asp:TextBox 上?
最佳答案
您可以使用 id selector并使用 focus()方法。要使用 jQuery,您需要 include jQuery并确保您的元素在访问之前在 DOM
中可用。您可以使用 document.ready为此。
$('#txt1').focus();
或者使用纯 JavaScript,focus()
document.getElementById('txt1').focus();
如果您没有 ClientIDMode = static 那么您将需要使用 ClientID
$('#<%= txt1.Client %>').focus();
关于javascript - 如何在 aspx 页面中将焦点设置在用户控件文本框上?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18310197/