jquery - 是:text case sensitive?

标签 jquery jquery-selectors

jQuery :text 选择器区分大小写吗?

例如:

<input type="TEXT">

不匹配但是:

<input type="text">

匹配。

情况似乎确实如此。我只是在寻找验证。

编辑

看起来甚至 [type=text] 选择器在 Chrome 和 Firefox 中也区分大小写,但在 IE8 中不区分大小写(在 IE8 文档模式下)

最佳答案

编辑:尽管我进行了研究,但我一开始还是得出了完全错误的结论。答案已更新:O(kudo 转到@ThiagoSantos,他从一开始就给出了正确的答案:D)。

jQuery ":text" documentation状态:

Because :text is a jQuery extension and not part of the CSS specification, queries using :text cannot take advantage of the performance boost provided by the native DOM querySelectorAll() method.

如果您深入了解source of 1.7.1看来这个选择器的实现如下:

text: function( elem ) {
    var attr = elem.getAttribute( "type" ), type = elem.type;
    // IE6 and 7 will map elem.type to 'text' for new HTML5 types (search, etc) 
    // use getAttribute instead to test this case
    return elem.nodeName.toLowerCase() === "input" && "text" === type && ( attr === type || attr === null );
}

对于<input type="tEXt" /> attr 的值结果是“tEXt”,与 type 不匹配。令我自己惊讶的是:

更新后的答案应该是::文本区分大小写

关于jquery - 是:text case sensitive?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8481480/

相关文章:

php - $.ajax jquery 到存储在 mysql 中的 php 脚本

jquery - 当前屏幕位置中心的绝对位置

jQuery 复选框 onChange

jQuery:选择器(带空格的类名)

javascript - 根据页面内容高度自动扩展侧边框

javascript - 调整窗口大小时显示隐藏元素的 slider

javascript - 比较两个 jquery ui 自动完成组合框值?

javascript - 单击跨度内的隐藏文件输入会导致 RangeError

jquery - 帮助捕获 DIV 中的属性数据排序作为数组吗? Jquery/Javascript

javascript - 带有 AND OR 条件的 jquery 多个选择器