我正在尝试使用html5和css计数器对文档中的数字进行编号.图编号css正在工作,但我需要能够生成包含图号的交叉引用.
有没有办法通过javascript访问这些值?我使用的计数器代码是:
body { counter-reset: section; }
section { counter-reset: figure;
counter-increment: section; }
section section { counter-reset: section; }
section > h1:before { content: counters(section, '.'); }
.figure > .caption:before {
counter-increment: figure;
content: 'Figure ' counters(section, '.') '-' counter(figure); }
section > h1:before, .figure > .caption:before { margin-right: .5em; }
Run Code Online (Sandbox Code Playgroud)