我遇到了一些麻烦。我有一个由 PHP 创建的表,它从 Excel 文件中提取数据。我想要做的是让用户能够在某些列(用户指定列)中搜索一个值(也是用户指定的),如果指定的值存在,则突出显示整行。
我一直在做功课,还没有找到合适的soulute。这是与我的噩梦相关的代码(:
$(document).ready(function(){
$("#search").click(function(){
var searchText;
if(col == 0 || col == 1 || col ==3){
searchText = $("#searchText").val()
}
else if(col == 6){
searchText = $("#maxPets option:selected").text();
}
else if(col == 7){
searchText = $("#maxWeight option:selected").text();
}
$("myTable tr td:nth-child(" + col +")").each(function () {
if ($(this).val.indexOf(searchText) !=-1) {
tr.addClass('result'); }
else {
tr.removeClass('result');
}
});
});
});