无法获取包含某些文本的表行的计数 [英] Trouble getting count of table rows that contain certain text

查看:57
本文介绍了无法获取包含某些文本的表行的计数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将包含某些文本的表行的计数输出到标签中.

I am trying to output the count of table rows that contain certain text into a label.

当我遍历JavaScript时,count变量最初包含count,但是在下一行时最终以undefined值结束.

When I step through my JavaScript, the count variable initially contains the count, but then ends up with a value of undefined when stepping to the next line.

var lblPending = document.getElementById("lblPending");
var count = $("#match-table tr").filter(function() { return $.text([this]) === 'Pending Credit'; }).length;


if (count > 0) {
lblPending.innerHTML = count + " Pending";
}
else {
$("#lblPending").hide();
}

是会导致这种回报的原因吗?

Is it the return that would be causing that?

推荐答案

这样的事情(使用contains):

$(function(){
   var myRows = $("#match-table tr:contains('Pending Credit')");
   $("#result").html(myRows.length + " Pending");
});

这篇关于无法获取包含某些文本的表行的计数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆