久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

如何在 css/js 屬性選擇器 [attr=value] 中正確轉義屬

How to properly escape attribute values in css/js attribute selector [attr=value]?(如何在 css/js 屬性選擇器 [attr=value] 中正確轉義屬性值?)
本文介紹了如何在 css/js 屬性選擇器 [attr=value] 中正確轉義屬性值?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

我應該如何在 css/js 屬性選擇器 [attr=value] 中轉義屬性?

How should I escape attributes in the css/js attibute selector [attr=value]?

具體來說,這樣對嗎?

document.querySelector('input[name="test[33]"]')

我正在尋找執行此操作的標準方式"(如果有的話),因為我不希望 Sizzle 使用執行繁重的后備功能

I'm looking for the "standard way" of doing this, if any, because I don't want Sizzle using a heavy-to-execute fallback function

推薦答案

是的,這是一種正確的方法.選擇器 3 級規范 聲明如下:

Yes, that is one correct approach. The Selectors Level 3 specification states the following:

屬性值必須是 CSS 標識符或字符串.

Attribute values must be CSS identifiers or strings.

您問題中的示例使用字符串作為屬性值.標識符"定義如下:

The example in your question uses a string as the attribute value. An "identifier" is defined as follows:

在 CSS 中,標識符...只能包含字符 [a-zA-Z0-9] 和 ISO 10646 字符 U+00A0 及更高,加上連字符 (-) 和下劃線 (_);它們不能以數字、兩個連字符或一個連字符后跟一個數字開頭.標識符還可以包含轉義字符和任何 ISO 10646 字符作為數字代碼...

In CSS, identifiers... can contain only the characters [a-zA-Z0-9] and ISO 10646 characters U+00A0 and higher, plus the hyphen (-) and the underscore (_); they cannot start with a digit, two hyphens, or a hyphen followed by a digit. Identifiers can also contain escaped characters and any ISO 10646 character as a numeric code...

因此,轉義特殊字符并省略引號也是合法的:

So following that, it is also legal to escape the special characters and omit the quotes:

document.querySelector('input[name=test\[33\]]')

這篇關于如何在 css/js 屬性選擇器 [attr=value] 中正確轉義屬性值?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

CSS selector when :target empty(:target 為空時的 CSS 選擇器)
Does the CSS direct decendant (gt;) not have any value in selectivity?(CSS 直接后代 (gt;) 在選擇性方面沒有任何價值嗎?)
Using querySelectorAll(). Is the result returned by the method ordered?(使用 querySelectorAll().方法返回的結果是否有序?)
Safari bug :first-child doesn#39;t update display:block when items are removed with JS(Safari 錯誤:當使用 JS 刪除項目時,first-child 不更新 display:block)
nth-Child CSS selectors(nth-子 CSS 選擇器)
Using same ID for multiple HTML tags?(對多個 HTML 標簽使用相同的 ID?)
主站蜘蛛池模板: 天堂中文在线资源 | 日本高清网站 | 国产精品香蕉 | 欧美二三区| 亚洲成a人片| 日韩精品久久久 | 日韩午夜在线观看 | 久久久在线| 日本在线看 | 日韩午夜片 | 99爱在线观看 | 亚洲综合婷婷 | 国产精品网站在线观看 | 免费黄网站在线观看 | 高清一区二区 | 午夜免费av | 性做久久久久久久免费看 | 国产成人精品一区二区三区在线观看 | 国产精品成人国产乱一区 | 中文字幕在线观看一区 | 特黄一级视频 | 日韩黄色一级片 | 天天摸夜夜操 | 日本一级黄色 | 91调教视频| 国产精品伦一区二区三级视频 | 久视频在线 | 国产精品毛片久久久久久久 | a一级黄色片 | 91激情网 | 国产成人tv | 欧美精品久久 | 国产一区二区福利 | 久久精品久久久 | 在线成人小视频 | 蜜桃精品视频 | 国产一级生活片 | 日韩综合精品 | 国产中文在线 | 午夜影院免费 | 亚洲高清免费 |