使用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 + "\n";
}
});
</script>

3、显示效果

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值