单击链接后,下面的代码会聚焦文本输入.它适用于Chrome 2.x,IE8和Opera 9.64,但不适用于Firefox 3.0.9.文本输入在Firefox中快速闪烁然后消失,我目前正在使用Windows XP SP2.
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3/jquery.min.js"></script>
<script>
$(document).ready(function()
{
$("a").click(function() {
var field_id = $(this).attr("href");
$(field_id).focus();
});
});
</script>
<a href="#text_field">Focus</a>
<input type="text" name="text_field" id="text_field" />
Run Code Online (Sandbox Code Playgroud)
有谁知道如何在Firefox中处理上述内容?
Dan*_*ura 10
我不知道你是否想要这个.要将焦点放在输入上,单击标签,您可以执行以下操作:
<label for="text_field">Label</label>
<input type="text" name="text_field" id="text_field" />
Run Code Online (Sandbox Code Playgroud)
要么
<label>Label
<input type="text" name="text_field" id="text_field" />
</label>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
18935 次 |
| 最近记录: |