Javascript jquery包装的CSS选择器对于chrome和IE 11有所不同

Javascript jquery包装的CSS选择器对于chrome和IE 11有所不同,javascript,jquery,html,css,internet-explorer,Javascript,Jquery,Html,Css,Internet Explorer,我有一个jquery包装的css选择器,比如$(“#选择器”).find('input[type=“textarea”])。我可以通过这个$(“#选择器”).find('input[type=“textarea”]).val(someValue)将值放到chrome中的输入区域,但不能通过Internet explorer 11 在开发工具中检查时, chrome给了我 [ input style=​"float:​ left;​ width:​ 70px;​ height:​ 21px;​

我有一个jquery包装的css选择器,比如
$(“#选择器”).find('input[type=“textarea”])
。我可以通过这个
$(“#选择器”).find('input[type=“textarea”]).val(someValue)
将值放到chrome中的输入区域,但不能通过Internet explorer 11

在开发工具中检查时, chrome给了我

[ 

input style=​"float:​ left;​ width:​ 70px;​ height:​ 21px;​ margin:​ 4px 2px 4px 4px;​" autocomplete=​"off" type=​"textarea" id=​"jqxWidget15f259b7" class=​"jqx-widget jqx-widget-energyblue jqx-input jqx-input-energyblue jqx-rc-all jqx-rc-all-energyblue jqx-widget-content jqx-widget-content-energyblue"

]
但是Internet explorer给了我一些不同的东西,比如一组对象

[object object]{context:undefined,jquery:“2.1.1”,长度:0,prevObject:object{…},选择器:“input[t
ype=…”}


有什么方法可以创建一个通用的jquery包装器来为两种浏览器的输入文本区域插入一个值吗?

CSS是特定于浏览器的,因此无法创建通用的jquery包装器。最好是特定于浏览器。您可以这样更改代码

$.browser.chrome = /chrom(e|ium)/.test(navigator.userAgent.toLowerCase());
        if ($.browser.chrome)
        {
            **Your Logic for Chrome**
        }
        else {
            **IE logic**
        }

为此,您可能必须包含JQUERY迁移插件。

这是IE11的一个缺陷。您应该在HTML和JavaScript代码中指定
text
,而不是
textarea


输入元素没有
textarea
类型。如果将此类无效类型指定给
type
属性,则将其视为默认
text
类型和
type
属性(非属性)返回
text
。IE的错误是不必要地将
type
属性值更新为
text

在您的代码中,我认为您错过了以下语句中的单引号:
$(“#选择器”).find('input[type=“textarea]”)val(someValue)
。它应该是
$($(“#选择器”).find('input[type=“textarea”).val(someValue)
。请尝试在结束方括号后添加单引号。不,这不是问题所在。当我在问题中输入jquery时,该引号可能会丢失。在Chrome中完全可以,但在IE11中无法获得任何内容。谢谢纳瓦内思的建议:)