use*_*142 4 html javascript firefox google-chrome autofocus
我正在使用Javascript创建我的页面.这是一个登录页面,我需要在用户名输入文本上使用自动对焦.此操作适用于IE和Chrome,但不适用于Mozilla!这是我用JS添加的HTML:
'<input id="username" class="loginInput" data-bind="value: userName, valueUpdate: \'afterkeydown\'" type="text" name="User" autofocus><!--User Input text end /-->'
Run Code Online (Sandbox Code Playgroud)
当我使用Mozilla加载页面时,此输入以这种方式设置:
<input id="username" class="loginInput" type="text" autofocus="" name="User" data-bind="value: userName, valueUpdate: 'afterkeydown'">
Run Code Online (Sandbox Code Playgroud)
我真的不明白为什么以这种方式设置"autofocus"属性.我甚至尝试使用JQuery添加属性$("#username").attr('autofocus','autofocus'),仅适用于Chrome和IE.
当我从另一个页面进入登录页面并且每个浏览器都出现自动对焦问题时,会出现第二个问题.
你能帮助我吗?
| 归档时间: |
|
| 查看次数: |
7154 次 |
| 最近记录: |