我是jquery的新手。我有一个从数据库中检索到的对象,我需要对它进行搜索。
$("#search-box").on("keyup", function searchnew() {
var g = $(this).val();
$(".dropdown.search-groups a").each( function() {
var s = $(this).text();
if (s.indexOf(g)!=-1) {
$(this).parent().parent().show();
}
else {
$(this).parent().parent().hide();
}
});
html中的相应代码是:
<form class="navbar-form navbar-left" role="search">
<div class="form-group">
<table>
<tr>
<td><input type="text" id="search-box" data-provide="typeahead" class="form-control" placeholder="Search" style="height:30px;" autocomplete="off"></td>
<td> </td>
<td><button type="submit" id="search-button" onclick="searchnew()" class="btn btn-default"> <!-- onClick="window.location = document.getElementById('search-box').value;"-->Go</button></td>
</tr>
</table>
<div class="other-groups">
<%
// Contains list of groups present in the organization
Object group[][]=groupBean.getGroup_details();
Integer i;
System.out.println("in dashboard before groups");
if(group!=null){
for(i=0;i<group.length;i++){
%>
<div>
<ul>
<td> </td>
<li class="dropdown" style="width:100%;"><div class="search-groups"><a href="#" class="dropdown-toggle" id="search-<%=i %>" style="text-decoration:none;color:black;"
data-toggle="dropdown" ><%=group[i][1]%><span class="caret"></span></a></div>
<ul class="dropdown-menu dropdown-menu-right" >
<li><a title="View and Manage All Voice Messages"
<% out.print("href='IvrsServlet?groupId="+group[i][0]+"&req_type=voiceMessage' target='right-iframe'"); %>>Voice Message Response<br>(आवाज संदेश प्रतिक्रिया)
</a></li>
<li><a title="Broadcast Voice/Text Messages"
<% out.print("href=IvrsServlet?req_type=voice&group_id="+group[i][0]+" target='right-iframe'"); %>>Broadcast<br>(प्रसारण)
</a></li>
<li><a title="Manage Call/Members of Group"
<% out.print("href='IvrsServlet?groupId="+group[i][0]+"&req_type=manage' target='right-iframe'"); %>>Manage<br>(प्रबंधित)
</a></li>
<li><a title="View and Manage All Text Messages"
<% out.print("href='IvrsServlet?groupId="+group[i][0]+"&req_type=textMessage' target='right-iframe'"); %>>Text Message Response<br>(पाठ संदेश प्रतिक्रिया)
</a></li>
<li><a title="View all Outgoing Text Messages of Group"
<% out.print("href='IvrsServlet?groupId="+group[i][0]+"&req_type=outgoingMessage' target='right-iframe'"); %>>Outgoing SMS<br>(जाने वाले संदेश)
</a></li>
</ul>
</li></ul>
</div>
<% }// end of for loop
}// end of if condition
%>
</div>
</div>
</form>
但这对我没有帮助。我该怎么办?