o*o 发帖数: 404 | 1 I have a search box in web page. How could I make it activated by default
as the page is loaded, so user can type in it directly? |
b****u 发帖数: 1027 | 2 use javascript, txtName.focus(); in onload event of the html body |
l*******9 发帖数: 177 | 3 最近在看jquery,发现干这些事情真是容易。。例如
给那个 input element 起个名字(id="MySearchBox"),
然后找个地方加上
$(document).ready(function(){
$("input#MySearchBox").focus();
});
这个 $(document).ready 就和 window.onload 差不多
不过可以多个共存而无需addEventListener,比直接用
window.onload方便多了。。。
【在 b****u 的大作中提到】 : use javascript, txtName.focus(); in onload event of the html body
|
o*o 发帖数: 404 | 4 thanks. It turned out that I need use setTimeout because it's a dialog info
popup window.
【在 b****u 的大作中提到】 : use javascript, txtName.focus(); in onload event of the html body
|