H2 heading numbering doesn't work correctly with paginated posts

主宰稳场 提交于 2019-12-12 03:40:00

问题


I'm using jQuery script from jQuery automatic heading numbering for H2 subtitle counting. I just updated the script little bit:

var h2Elements = $('article').find('h2');            
       var h2ElemCount = h2Elements.length;        
        $(h2Elements).each(function(i) {    
       $(this).prepend(h2ElemCount - i + '. ');    
          }); 

it works perfectly if the article is showed in the single page. When I paginate the post (because there are 10 to 15 subtitles) the counting starts from 1 for each subpage in article. How to keep the heading numbering throw whole article?

来源:https://stackoverflow.com/questions/43397234/h2-heading-numbering-doesnt-work-correctly-with-paginated-posts

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!