【发布时间】:2017-03-16 00:03:44
【问题描述】:
我有一些框 div 类,我希望当用户在搜索框中输入任何内容时,它会显示这些框和那些框(过滤它)。当前代码将在显示用户在搜索框中输入的内容之前删除所有框。谢谢!
<!-- Search box -->
<input type="text" id="txt_name" />
<!-- Search button-->
<input type="button" id="searchTest" value="Search"/>
<!-- Searching for the ID that the user enter -->
<script language='JavaScript' type='text/JavaScript'>
$('#searchTest').click(function() {
// removes all the div class before displaying the results
$('div[id*=ID_]').css('display', 'none');
//display only whatever the user's entered
$('div[id*=ID_]').filter(bla).css('display', 'block');
});
</script>
<!-- Test boxes that needs filtering-->
<div class="color1" id="USEID_company1_user1_Location1">
<p> test</p>
</div>
<div class="color2" id="USEID_company2_user2_Location2">
<p> test</p>
</div>
【问题讨论】:
标签: jquery html css search filter