diff options
author | Peter Bengtsson <mail@peterbe.com> | 2020-12-08 14:40:17 -0500 |
---|---|---|
committer | Peter Bengtsson <mail@peterbe.com> | 2020-12-08 14:40:17 -0500 |
commit | 33058f2b292b3a581333bdfb21b8f671898c5060 (patch) | |
tree | 51c3e392513ec574331b2d3f85c394445ea803c6 /files/zh-cn/web/api/cssstylerule/selectortext | |
parent | 8b66d724f7caf0157093fb09cfec8fbd0c6ad50a (diff) | |
download | translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.gz translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.bz2 translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.zip |
initial commit
Diffstat (limited to 'files/zh-cn/web/api/cssstylerule/selectortext')
-rw-r--r-- | files/zh-cn/web/api/cssstylerule/selectortext/index.html | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/files/zh-cn/web/api/cssstylerule/selectortext/index.html b/files/zh-cn/web/api/cssstylerule/selectortext/index.html new file mode 100644 index 0000000000..76a9007cd3 --- /dev/null +++ b/files/zh-cn/web/api/cssstylerule/selectortext/index.html @@ -0,0 +1,33 @@ +--- +title: CSSStyleRule.selectorText +slug: Web/API/CSSStyleRule/selectorText +translation_of: Web/API/CSSStyleRule/selectorText +--- +<div>{{APIRef("CSSOM") }}</div> + +<h2 id="Summary" name="Summary">概述</h2> + +<p><code><strong>CSSRule.selectorText</strong></code> 属性返回CSS规则的选择符文本,只读。动态设置CSS规则,请看 <a href="/en-US/docs/DOM/Using_dynamic_styling_information" title="/en-US/docs/DOM/Using_dynamic_styling_information">Using dynamic styling information</a>.</p> + +<h2 id="Syntax" name="Syntax">语法</h2> + +<pre class="syntaxbox"><em>string</em> = cssRule.selectorText +</pre> + +<h2 id="Example" name="Example">例子</h2> + +<pre class="brush: js">// for cssrule: body { background-color: darkblue; } +var stylesheet = document.styleSheets[0]; + +alert(stylesheet.cssRules[0].selectorText); // body +</pre> + +<h2 class="Notes" id="说明">说明</h2> + +<p>浏览器解析选择符的时候可能会剔除不必要的空白字符</p> + +<h2 id="Specification" name="Specification">标准</h2> + +<ul> + <li><a href="http://www.w3.org/TR/DOM-Level-2-Style/css.html#CSS-CSSRule" title="Document Object Model CSS #CSS-CSSRule">Document Object Model CSS - #CSS-CSSRuleCSS</a></li> +</ul> |