zoukankan      html  css  js  c++  java
  • 使用jquery脚本获取随笔、文章和评论的统计数,自定义显示位置

      为了这个问题,花了好些时间去摸索,无奈没有搞定。于是,我就到博问去提问,终于搞定!

      在此,非常感谢SeayXu的热心帮助。

    1、在需要的位置添加一个标签

    <div id="stats_count_show"></div>

    2、首页html页面添加js代码

    <script type="text/javascript">
    $(function() {
    setTimeout(getAllCount, 3000);
    
    function getAllCount() {
        var post = document.getElementById('stats_post_count').innerText.replace(/.*?(d+).*?/g, '$1');
        var article = document.getElementById('stats_article_count').innerText.replace(/.*?(d+).*?/g, '$1');
        var comment = document.getElementById('stats-comment_count').innerText.replace(/.*?(d+).*?/g, '$1');
        post = post != null || post != "" ? post : 0;
        article = article != null || article != "" ? article : 0;
        comment = comment != null || comment != "" ? comment : 0;
        document.getElementById('stats_count_show').innerText = "随笔 - " + post + " 文章 - " + article + " 评论 - " + comment + "
    ";
    }
    });
    </script>

    3、显示效果

  • 相关阅读:
    开源协议
    开发新技能
    UML 思维导图 思维脑图 xmind
    小方法
    Android Service
    JS 下载图片
    quartz任务执行完之后再执行下一轮任务
    easyui 下边有滚动条问题
    微信支付证书 系统找不到指定的文件
    Swiper 动态加载数据没有变化问题
  • 原文地址:https://www.cnblogs.com/dinphy/p/5877023.html
Copyright © 2011-2022 走看看