Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/83.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 占位符在IE 9中不起作用,但在chrome中可以使用_Jquery_Html_Internet Explorer - Fatal编程技术网

Jquery 占位符在IE 9中不起作用,但在chrome中可以使用

Jquery 占位符在IE 9中不起作用,但在chrome中可以使用,jquery,html,internet-explorer,Jquery,Html,Internet Explorer,可能重复: 一个非常简单的测试 我的代码: <div id="generatePinsDialog" > <label for="newCount" style="width: 400px;"> How many?</label> <input id="newCount" type="text" size="25" placeholder="Enter the number!" /> <br /> 它在谷歌chrome上运行

可能重复:

一个非常简单的测试

我的代码:

<div id="generatePinsDialog" >
<label for="newCount" style="width: 400px;">
    How many?</label>
<input id="newCount" type="text" size="25" placeholder="Enter the number!" />
<br />
它在谷歌chrome上运行,但在IE 9上运行


感谢您更正代码。

占位符属性在IE中不起作用,只在现代浏览器中起作用。不过,IE10现在终于做到了


大多数情况下,像这样的东西在现代浏览器中都会起作用,但你需要经常仔细检查它在IE中是否起作用,而IE通常比其他浏览器落后数年。一个位置是

假设您只想检查浏览器是否支持占位符,您可以使用以下代码:

jQuery(function() {
     jQuery.support.placeholder = ( 'placeholder' in (document.createElement( 'input' )) );
});

除此之外,如评论中所述,IE9不支持占位符
(请参阅)

但是如果你在JSFIDLE中查看它,它不会在IE9中显示文本。如果你绝对需要这种功能,那么使用Javascript是目前唯一一个跨浏览器兼容的解决方案。
jQuery(function() {
     jQuery.support.placeholder = ( 'placeholder' in (document.createElement( 'input' )) );
});