久久久久久久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?)
主站蜘蛛池模板: 亚洲久久一区 | 一道本不卡视频 | 色婷婷av久久久久久久 | 亚洲成人精品 | 一区不卡在线观看 | 91精品久久久久久久久中文字幕 | 国产在线观看av | 一区二区三区四区av | 看片91 | 羞羞视频在线观看 | 国产一区 | 成人在线观| 欧美极品在线观看 | 精品国产91乱码一区二区三区 | 男女精品久久 | 91不卡| 欧美成人一区二免费视频软件 | 少妇精品久久久久久久久久 | 精品一区二区久久久久久久网站 | 一区二区成人 | 国产一区二区久久 | 欧美a∨| 久久综合久| 国产精品久久久久无码av | 免费视频一区二区三区在线观看 | 欧美久久电影 | 欧洲妇女成人淫片aaa视频 | 色综合天天综合网国产成人网 | 毛片一级片 | 国产免费a| 殴美黄色录像 | 久久久久久国产精品免费免费狐狸 | 男女污网站| 免费久久精品 | 亚洲第一av | 久久久久久久久久久久久91 | 国产一区二区三区 | 九九视频网 | aaa综合国产 | 午夜国产在线 | 97avcc|