Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/82.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
JQuery在id输入字段上聚焦并选择_Jquery_Input_Autofocus - Fatal编程技术网

JQuery在id输入字段上聚焦并选择

JQuery在id输入字段上聚焦并选择,jquery,input,autofocus,Jquery,Input,Autofocus,不专注于球场?如何纠正这一点 这里需要一些引号: document.getElementById('introdukt').focus() document.getElementById('introdukt').select() 这是一个工作,尽管你在上面使用了不同的ID 你没有正确使用选择器。检查我的小提琴 还有,我把你小提琴上的id改回了你的名字 另外,如果您要使用jquery document ready,您也可以使用jquery选择器而不是纯js方法。您可以不用js,只需使用html

不专注于球场?如何纠正这一点

这里需要一些引号:

document.getElementById('introdukt').focus()
document.getElementById('introdukt').select()
这是一个工作,尽管你在上面使用了不同的ID

你没有正确使用选择器。检查我的小提琴

还有,我把你小提琴上的id改回了你的名字


另外,如果您要使用jquery document ready,您也可以使用jquery选择器而不是纯js方法。

您可以不用js,只需使用html属性即可:

<input autofocus type="text" size="12" id="introdukt" value="match" style="text-align:center"  />

看看这把小提琴:

在中检查更新的脚本

HTML:


您应该链接方法调用,因为jQuery只需要查找元素一次

$(document).ready(function ()
{  
    $('#introdukt').focus().select();
});

无需选择两次-使用链接$'Introduct'。focus.select@这是真的。我真的不记得回答过这个问题,但我相信我这样做是为了更清楚地展示。不管是谁,我会给出答案,因为根据你的说法,人们实际上使用这个:D
<input autofocus type="text" size="12" id="introdukt" value="match" style="text-align:center"  />
<input type="text" size="12" id="czasow1introdukt" value="match" style="text-align:center"/>
$(document).ready(function ()
{  
     document.getElementById('czasow1introdukt').focus()
    document.getElementById('czasow1introdukt').select()
});
$(document).ready(function ()
{  
    $('#introdukt').focus().select();
});