选择器不区分大小写? [英] Case insensitivity in selectors?

查看:112
本文介绍了选择器不区分大小写?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用jQuery进行XML处理.我被jQuery困扰的问题之一是,它在处理标签和属性时不区分大小写.

I am trying to use jQuery for XML processing. One of the problem that I am stuck with jQuery is it is case insensitive in processing tags and attribute.

例如,考虑以下代码:

$("<div><Book ISBN='1234'>Some title</Book></div>").html()

我们得到的输出是:

<book isbn="1234">Some title</book>

我正在寻找的输出是:

<Book ISBN="1234">Some title</Book>

有可能吗? (请注意,"B"为大写字母,整个属性名称"ISBN"也为大写字母,而jQuery html输出为小写).

Any possibility? (Note that "B" is capital letter, and the whole attribute name "ISBN" is also in capital case, whereas the jQuery html output is completely lower case) Please help.

推荐答案

根据 http ://www.w3.org/TR/CSS21/selector.html (以HTML格式) 元素名称不区分大小写,但在XML中,它们区分大小写- 敏感的.属性名称也是如此.

According to http://www.w3.org/TR/CSS21/selector.html, in HTML element names are case-insensitive, but in XML they are case- sensitive. The same is true for attribute names.

因此,您得到的HTML输出是正确的.据我所知, jQuery核心无法创建HTML文档,因为区分大小写对于元素和属性名称至关重要.

So, the HTML output you are getting is correct. To my knowledge, jQuery core can't create an HTML document, where case sensitivity matters for element and attribute names.

请参见下文.我最初说过jQuery无法创建区分大小写的XML文档.显然可以.但是,如果要注入HTML,就无法保留这种情况.有关解决方案,请参见:将XML标签转换为大写的jQuery

See below. I had originally said jQuery can't create an XML document where case sensitivity matters. Clearly, it can. But it can't preserve the case if you're injecting into HTML. For a solution, see: jQuery converting XML tags to uppercase

这篇关于选择器不区分大小写?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆