大型HTML页面上的jQuery搜索

大型HTML页面上的jQuery搜索,jquery,search,Jquery,Search,我有一项工作要完成。我有一个带有产品表的HTML页面。我需要提供一个搜索框,允许用户输入要搜索的产品,然后使用jQuery搜索页面中匹配的单词,然后将它们附加到表上方的div中,并获取它们链接到的href 无法搜索数据库,因为我没有访问服务器的权限,以前有没有人这样做过,或者看到过任何好的资源或插件。这似乎是一项相对容易的任务,但我时间不够 下面是我刚刚编写的代码,除了在比较小写/大写字母时遇到困难外,效果非常好。任何想法 $(document).ready(function() { $('#s

我有一项工作要完成。我有一个带有产品表的HTML页面。我需要提供一个搜索框,允许用户输入要搜索的产品,然后使用jQuery搜索页面中匹配的单词,然后将它们附加到表上方的div中,并获取它们链接到的href

无法搜索数据库,因为我没有访问服务器的权限,以前有没有人这样做过,或者看到过任何好的资源或插件。这似乎是一项相对容易的任务,但我时间不够

下面是我刚刚编写的代码,除了在比较小写/大写字母时遇到困难外,效果非常好。任何想法

$(document).ready(function() {
$('#searchButton').click(function() {
$(".searchresults").slideUp('fast', function(){

var arr = [];
var htmlsbr = "Your Search Results:<br />";

$('a:contains("' + $('#searchText').val() + '")').each(function() {
                                   arr.push($(this).text()+";"+$(this).attr('href'));
});

$.each(arr, function(index, value) { 
htmlsbr = htmlsbr + '<p><a href="'+value.split(';')[1]+'" name="'+value.split(';    ')[0]+'">'+value.split(';')[0]+'</a></p>';
});

$(".searchresults").append(htmlsbr).slideDown('slow');

}).html(' ');
});
});

</script>
<style>
p {color: brown;}
p.highlight {background-color: orange;}
body {background-color: beige;}
</style>
</head>
<body>
<div class="searchresults"></div>
<input id="searchText" value="second" />
<button id="searchButton">Search</button>
<p><a href="http://google.com" rel="this is the first entry.">This is the first entry.    </a></p>
<p><a href="http://ebay.com" rel="this is the second entry">This is the second entry.    </a></p>
<p><a href="http://msn.com" rel="this is the third entry.">This is the third entry.    </a></p>
<p><a href="http://yahoo.com" rel="this is the fourth entry.">This is the fourth entry.    </a></p>'
可以做这项工作。

您可以使用

未测试的示例-

jQuery('selector').replaceText($("#yourtextbox").val(),function (str) {
    //do your stuff
}));

谢谢,不幸的是,我宁愿使用更轻的东西,因为它需要在IE6中工作。