[英]When web page is loaded , how to focus a textbox in ipad browser?
網頁加載后,我想突出顯示文本框。 這些代碼在PC瀏覽器(Google chrome,互聯網瀏覽器等)上執行,但是如果您在Ipad瀏覽器上輸入,則無法使用。 問題是什么 ? 這個問題對我來說很重要。 請..
<asp:TextBox ID="txt_arama2" runat="server" Width="60%"></asp:TextBox>
window.onload = function() {
document.getElementById("txt_arama2").focus();
};
問題是,當呈現asp文本框時, ID
會將其名稱更改為如下所示:
ctl00$m$g_5283b87a_5e59_4ac5_8266_7c4bd2119e8d$ctl00$txt_arama2
嘗試添加一個類,然后使用class
屬性訪問該元素。
<asp:TextBox ID="txt_arama2" CssClass="myClass" runat="server" Width="60%"></asp:TextBox>
window.onload = function() {
document.getElementsByClassName("myClass")[0].focus();
};
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.