html5自訂標籤選取器

來源:互聯網
上載者:User

標籤:

* E[attr]:只使用屬性名稱,但沒有確定任何屬性值

* E[attr="value"]:指定屬性名稱,並指定了該屬性的屬性值。必須和元素的屬性完全符合

* E[attr~="value"]:指定屬性名稱,並且具有屬性值,此屬性值是一個詞列表,並且以空格隔開,其中詞列表中包含了一個value詞,而且等號前面的“?”不能不寫

* E[attr^="value"]:指定了屬性名稱,並且有屬性值,屬性值是以value開頭的

* E[attr$="value"]:指定了屬性名稱,並且有屬性值,而且屬性值是以value結束的,與E[attr^="value"]相反

* E[attr*="value"]:指定了屬性名稱,並且有屬性值,而且屬值中包含了value

* E[attr|="value"]:指定了屬性名稱,並且屬性值是value或者以“value-”開頭的值(比如說zh-cn)

document.querySelector("[data-klass=‘ppss‘]");

高端人士甚至連偽類也玩弄於鼓掌之中了:

<!DOCTYPE html><title>CSS</title><style>    body {        font: 200%/1.45 charter;    }    ref::before {        content: ‘\00A7‘;        letter-spacing: .1em;    }</style><article>The seller can, under Business Law <ref>1782</ref>, offer a full refund to buyers. </article><script>    function ruleSelector(selector) {        function uni(selector) {            return selector.replace(/::/g, ‘:‘)        }        return Array.prototype.filter.call(Array.prototype.concat.apply([], Array.prototype.map.call(document.styleSheets, function(x) {            return Array.prototype.slice.call(x.cssRules);        })), function(x) {            return uni(x.selectorText) === uni(selector);        });    }    var toggle = false,         pseudo = ruleSelector("ref::before").slice(-1);    document.querySelector("article").onclick = function() {        pseudo.forEach(function(rule) {            if (toggle = !toggle)                rule.style.color = "red";            else                rule.style.color = "black";        });    }</script>

一般來說是沒辦法選中:after的,用擴充方法改變偽類的樣式,實在厲害。

html5自訂標籤選取器

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.