Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/406.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/89.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
select可以工作,但是Javascript.select不能_Javascript_Jquery_Windows Mobile_Internet Explorer 6 - Fatal编程技术网

select可以工作,但是Javascript.select不能

select可以工作,但是Javascript.select不能,javascript,jquery,windows-mobile,internet-explorer-6,Javascript,Jquery,Windows Mobile,Internet Explorer 6,我正在为摩托罗拉/IE6设备建立一个移动站点 出于某种我想不出来的原因,jQuery的.select()函数正在工作,但在javascript中直接调用它却不行 <input type="text" id="lid" value="" class="as_done"> 不起作用的方式是: document.getElementById('lid').select(); 这让我有点困惑。你知道为什么会这样吗 编辑:我不想在jQuery中做任何事情。我只是想在输入框中选择文本。我不

我正在为摩托罗拉/IE6设备建立一个移动站点

出于某种我想不出来的原因,jQuery的.select()函数正在工作,但在javascript中直接调用它却不行

<input type="text" id="lid" value="" class="as_done">
不起作用的方式是:

document.getElementById('lid').select();

这让我有点困惑。你知道为什么会这样吗


编辑:我不想在jQuery中做任何事情。我只是想在输入框中选择文本。我不需要jQuery来做这件事,但是标准的方法不起作用

$()函数返回一个jquery对象,而document.getElementById返回一个简单的DOM对象。

可能是因为您事先没有调用.focus()

document.getElementById('lid').focus();
document.getElementById('lid').select();

这是用jQuerys.select()包装的。有趣的变化使它对我有用。也许这是WindowsMobile IE6中的一个bug

考虑以下html:

<input type="hidden" id="lid_as" name="lid" value="1">
<input type="text" id="lid" value="" class="as_done">

同样,这个问题与WindowsMobileIE6有关。

它确实有效->fiddle在firefox中不起作用。。。我假设它在Webkit浏览器中也能工作。。。编辑:是否适用于ChromeNotice windows mobile/IE 6…请在下面签出我的答案,并尝试在调用本机选择器之前以本机方式聚焦输入。我确实尝试了此操作,但没有更改结果。然而,我发布了一个关于是什么为我解决了这个问题的答案。我认为这是一个移动浏览器故障。我看到类型“HTMLElement”上不存在属性“select”。您的意思是“onselect”@AlexanderMills取决于您选择的HTMLElement类型。该方法存在于接受输入的元素上,例如HTMLTextAreaElement,但不存在于每个HtmlElementSeing此。。。我认为这是一个已知的bug,ID和NAME可以同时使用,也可以相互替换other@TobiasKrogh,我只是在谷歌上搜索了一下,也找到了那个链接。我在那里拔了拔头发。。。呸。
<input type="hidden" id="lid_as" name="lid" value="1">
<input type="text" id="lid" value="" class="as_done">
<input type="text" id="lid" value="" class="as_done">
<input type="hidden" id="lid_as" name="lid" value="1">