【发布时间】:2017-04-12 22:42:12
【问题描述】:
我在网站上有 10-15 个 H2 标签字幕的文章。喜欢这样的东西。
<h1>Name of article</h1>
<h2>Subtitle</h2>
<p>.....</p>
<h2>Subtitle</h2>
<p>.....</p>
<h2>Subtitle</h2>
<p>.....</p>
<h2>Subtitle</h2>
<p>.....</p>
那么,问题是如何通过 jQuery 以降序自动为每个 H2 标签(字幕)指定编号?
<h1>Name of article</h1>
<h2>15.Subtitle</h2>
<p>.....</p>
<h2>14.Subtitle</h2>
<p>.....</p>
<h2>13.Subtitle</h2>
<p>.....</p>
<h2>12.Subtitle</h2>
<p>.....</p>
我知道如何通过 CSS 计数器来实现,但文章可以包含不同数量的字幕。我检查过类似的Automatic Numbering of Headings H1-H6 using jQuery 主题,但这不是我想要的。
【问题讨论】:
标签: jquery automation html-heading css-counter