Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/367.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/71.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 在函数jquery中计算和显示已完成的项目_Javascript_Jquery_Wordpress - Fatal编程技术网

Javascript 在函数jquery中计算和显示已完成的项目

Javascript 在函数jquery中计算和显示已完成的项目,javascript,jquery,wordpress,Javascript,Jquery,Wordpress,我有一个Jquery函数,可以根据以下函数对待办事项列表中已完成/未完成的项目进行排序: $('.sort').click(function(){ var _t = $(this); $('.sort').removeClass('active'); $(this).addClass('active'); if (_t.hasClass('showall')) { $('li.todo').show(); } else if (_

我有一个Jquery函数,可以根据以下函数对待办事项列表中已完成/未完成的项目进行排序:

$('.sort').click(function(){
    var _t = $(this);
    $('.sort').removeClass('active');
    $(this).addClass('active');

    if (_t.hasClass('showall')) {
        $('li.todo').show();
    }
    else if (_t.hasClass('complete')) {
        $('li.todo').show();
        $('li.todo').filter(function(){
            return !!$(this).find('span.uncheck_box').length;
        }).hide();
    }
    else if (_t.hasClass('incomplete')) {
        $('li.todo').show();
        $('li.todo').filter(function(){
            return !!$(this).find('span.check_box').length;
        }).hide();
    }
如何在wordpress中获取并显示已完成项目的计数。请帮忙


谢谢。

console.log($('span.complete').length)
@ubercooluk谢谢,但我想将其显示为一个带有单独div的按钮。如何实现此目的?只需在页面中放置一个按钮
get count
,然后使用此代码
$(文档)。就绪(function(){$('#count')。单击(function(){console.log($('span.complete').length);})
@ubercoolk谢谢..上面的代码似乎不起作用。我甚至用它在页面上显示计数,但同样没有运气
$(document).ready(function(){$('.2').show();})$(function(){var numrelated=$('.relatedelements>span.check_box').length;$('.num relatedelements').html(numrelated);})