带有复选框PHP的实时搜索过滤器 [英] Live Search Filter with Checkbox PHP
本文介绍了带有复选框PHP的实时搜索过滤器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我对带有复选框的实时搜索有疑问。我的问题是,当我搜索一个名称列表时,复选框会自动选中。
I have issue about the live search with check box. My problem is when i search one the name list the check box is automatically check. only the showed data check.
示例我搜索世界 vin
,都必须检查单词vin。
example i search world "vin" all have word vin must be checked.
这是我的 [样本] [1]
[1]: http://jsfiddle.net/v921/TxYqv/3/
推荐答案
更新后的答案:
这是您的js的外观:
function filter(element) {
var $trs = $('.AvailableGroupLab tr').hide();
var regexp = new RegExp($(element).val(), 'i');
var $numberOfShownRows = 0;
var $rows = $trs.filter(function () {
if($(element).val() != "")
{
$(this).children(':nth-child(1)').html("<input type='checkbox' checked />");
}
else
{
$(this).children(':nth-child(1)').html("<input type='checkbox' />");
}
return regexp.test($(this).children(':nth-child(2)').text());
});
$rows.show();
if($rows.length == 0)
{
$('#message').show();
}
else
{
$('#message').hide();
}
}
$('input:text').on('keyup change', function () {
filter(this);
})
然后将此 div
放到任何地方您要输入文字:
And put this div
whereever you want to put your text:
<div id="message" style="display:none"> No record! </div>
这篇关于带有复选框PHP的实时搜索过滤器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文