aboutsummaryrefslogtreecommitdiff
path: root/files/zh-cn/web/api/htmldetailselement
diff options
context:
space:
mode:
authorPeter Bengtsson <mail@peterbe.com>2020-12-08 14:40:17 -0500
committerPeter Bengtsson <mail@peterbe.com>2020-12-08 14:40:17 -0500
commit33058f2b292b3a581333bdfb21b8f671898c5060 (patch)
tree51c3e392513ec574331b2d3f85c394445ea803c6 /files/zh-cn/web/api/htmldetailselement
parent8b66d724f7caf0157093fb09cfec8fbd0c6ad50a (diff)
downloadtranslated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.gz
translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.bz2
translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.zip
initial commit
Diffstat (limited to 'files/zh-cn/web/api/htmldetailselement')
-rw-r--r--files/zh-cn/web/api/htmldetailselement/index.html44
-rw-r--r--files/zh-cn/web/api/htmldetailselement/toggle_event/index.html120
2 files changed, 164 insertions, 0 deletions
diff --git a/files/zh-cn/web/api/htmldetailselement/index.html b/files/zh-cn/web/api/htmldetailselement/index.html
new file mode 100644
index 0000000000..6b554dc11b
--- /dev/null
+++ b/files/zh-cn/web/api/htmldetailselement/index.html
@@ -0,0 +1,44 @@
+---
+title: HTMLDetailsElement
+slug: Web/API/HTMLDetailsElement
+translation_of: Web/API/HTMLDetailsElement
+---
+<p>{{APIRef("HTML DOM")}}</p>
+
+<p><strong><code>HTMLDetailsElement</code></strong> 接口提供了特殊的属性 (除了常规的 {{domxref("HTMLElement")}} 接口之外,它还可以通过继承获得这些属性) 用于操作 {{HTMLElement("details")}} 元素.</p>
+
+<p>{{InheritanceDiagram(600, 120)}}</p>
+
+<h2 id="属性">属性</h2>
+
+<p><em>从其父级 {{domxref("HTMLElement")}} 继承属性.</em></p>
+
+<dl>
+ <dt>{{domxref("HTMLDetailsElement.open")}}</dt>
+ <dd>是一个 {{domxref("boolean")}} 反射 {{htmlattrxref("open", "details")}} HTML属性, 指示是否向用户显示元素的内容 (不包括 {{HTMLElement("summary")}})</dd>
+</dl>
+
+<h2 id="方法">方法</h2>
+
+<p><em>没有特定的方法;继承其父方法 {{domxref("HTMLElement")}}.</em></p>
+
+<h2 id="规格">规格</h2>
+
+<ul>
+ <li><a href="https://html.spec.whatwg.org/multipage/interactive-elements.html#htmldetailselement">HTML Living Standard</a></li>
+ <li><a href="https://www.w3.org/TR/html52/interactive-elements.html#htmldetailselement">HTML 5.2 (W3C Proposed Recommendation)</a></li>
+</ul>
+
+<h2 id="浏览器兼容性">浏览器兼容性</h2>
+
+<div>
+<div class="hidden"><a href="https://github.com/mdn/browser-compat-data">此页上的兼容性表是从结构化数据生成的。如果您想贡献数据,请访问 https://github.com/mdn/browser-compat-data</a> 并向我们发送一个请求。</div>
+
+<p>{{Compat("api.HTMLDetailsElement")}}</p>
+</div>
+
+<h2 id="另见">另见</h2>
+
+<ul>
+ <li>实现此接口的HTML元素: {{HTMLElement("details")}}</li>
+</ul>
diff --git a/files/zh-cn/web/api/htmldetailselement/toggle_event/index.html b/files/zh-cn/web/api/htmldetailselement/toggle_event/index.html
new file mode 100644
index 0000000000..b1129b4298
--- /dev/null
+++ b/files/zh-cn/web/api/htmldetailselement/toggle_event/index.html
@@ -0,0 +1,120 @@
+---
+title: 'HTMLDetailsElement: toggle event'
+slug: Web/API/HTMLDetailsElement/toggle_event
+translation_of: Web/API/HTMLDetailsElement/toggle_event
+---
+<div>
+<p>{{APIRef}}</p>
+
+<p>当{{HtmlElement("details")}}元素<code>打开</code>/<code>关闭</code>状态被切换时,切换事件会触发。</p>
+
+<table>
+ <tbody>
+ <tr>
+ <th>Bubbles</th>
+ <td>No</td>
+ </tr>
+ <tr>
+ <th>Cancelable</th>
+ <td>No</td>
+ </tr>
+ <tr>
+ <th>Interface</th>
+ <td>{{DOMxRef("Event")}}</td>
+ </tr>
+ <tr>
+ <th>Event handler property</th>
+ <td>None</td>
+ </tr>
+ <tr>
+ <th>Default Action</th>
+ <td>Toggles the <code>open</code> state of the {{HtmlElement("details")}} element.</td>
+ </tr>
+ </tbody>
+</table>
+
+<h2 id="例子">例子</h2>
+
+<p>此示例记录打开的章节。 当章节关闭时,它们将从日志中删除。</p>
+
+<h3 id="HTML">HTML</h3>
+
+<pre class="notranslate">&lt;aside id="log"&gt;
+ &lt;b&gt;Open chapters:&lt;/b&gt;
+ &lt;div data-id="ch1" hidden&gt;I&lt;/div&gt;
+ &lt;div data-id="ch2" hidden&gt;II&lt;/div&gt;
+ &lt;div data-id="ch3" hidden&gt;III&lt;/div&gt;
+&lt;/aside&gt;
+&lt;section id="summaries"&gt;
+ &lt;b&gt;Chapter summaries:&lt;/b&gt;
+ &lt;details id="ch1"&gt;
+ &lt;summary&gt;Chapter I&lt;/summary&gt;
+ Philosophy reproves Boethius for the foolishness of his complaints against Fortune. Her very nature is caprice.
+ &lt;/details&gt;
+ &lt;details id="ch2"&gt;
+ &lt;summary&gt;Chapter II&lt;/summary&gt;
+ Philosophy in Fortune's name replies to Boethius' reproaches, and proves that the gifts of Fortune are hers to give and to take away.
+ &lt;/details&gt;
+ &lt;details id="ch3"&gt;
+ &lt;summary&gt;Chapter III&lt;/summary&gt;
+ Boethius falls back upon his present sense of misery. Philosophy reminds him of the brilliancy of his former fortunes.
+ &lt;/details&gt;
+&lt;/section&gt;</pre>
+
+<h3 id="CSS">CSS</h3>
+
+<pre class="notranslate">body {
+ display: flex;
+ flex-direction: row-reverse;
+}
+
+#log {
+ flex-shrink: 0;
+ padding-left: 3em;
+}
+
+#summaries {
+ flex-grow: 1;
+}</pre>
+
+<h3 id="JavaScript">JavaScript</h3>
+
+<pre class="notranslate">function logItem(e) {
+ const item = document.querySelector(`[data-id=${e.target.id}]`);
+ item.toggleAttribute('hidden');
+}
+
+const chapters = document.querySelectorAll('details');
+chapters.forEach((chapter) =&gt; {
+ chapter.addEventListener('toggle', logItem);
+});</pre>
+
+<h3 id="Result">Result</h3>
+
+<p>{{EmbedLiveSample("Examples", 700, 200)}}</p>
+
+<h2 id="规范">规范</h2>
+
+<table>
+ <thead>
+ <tr>
+ <th scope="col">Specification</th>
+ <th scope="col">Status</th>
+ <th scope="col">Comment</th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr>
+ <td>{{SpecName('HTML WHATWG', 'indices.html#event-toggle', 'toggle event')}}</td>
+ <td>{{Spec2("HTML WHATWG")}}</td>
+ <td></td>
+ </tr>
+ </tbody>
+</table>
+
+<h2 id="浏览器兼容性">浏览器兼容性</h2>
+
+<p>The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out <a href="https://github.com/mdn/browser-compat-data">https://github.com/mdn/browser-compat-data</a> and send us a pull request.</p>
+
+<p>{{Compat("api.HTMLDetailsElement.toggle_event")}}</p>
+</div>