久久久久久久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?)
主站蜘蛛池模板: 91精品国产综合久久久久久丝袜 | 免费精品久久久久久中文字幕 | 日韩亚洲一区二区 | 国产成都精品91一区二区三 | 国产精品精品3d动漫 | 日韩在线看片 | 国产日韩精品在线 | 国产欧美精品区一区二区三区 | 国产午夜精品久久久久 | 久久精品国产一区二区三区 | 国产精品久久国产精品 | 日韩精品久久久久 | 无码一区二区三区视频 | 丁香五月网久久综合 | 国产草草视频 | 免费在线看a | 7777在线视频免费播放 | 爱爱视频在线观看 | 欧美一a一片一级一片 | 91视在线国内在线播放酒店 | 精品伊人| 亚洲精品电影在线观看 | 亚洲欧美在线观看 | 韩日精品视频 | 欧美一级片免费看 | 激情欧美一区二区三区中文字幕 | 亚洲精品电影在线观看 | 中文日韩在线视频 | 91在线网| 国产成人在线一区 | 久久99精品久久久久蜜桃tv | 国产一级片免费看 | 午夜网址| 可以免费看的毛片 | 日韩在线免费电影 | 久久国产成人 | 美女操网站 | 午夜视频一区 | 超碰人人艹 | 亚洲二区视频 | 国产三级电影网站 |