我创建了一个从数据库获取数据的页面,并将数据输出到一个表中。我想对我的桌子进行实时搜索,所以下面的脚本是我在互联网上找到的。
现在CSS中使用了奇数和偶数样式。如果我搜索表,样式会很奇怪,因为它从一开始就应用样式,而不是搜索后的样式。
问题:在搜索后,我有多个相同颜色的tr
脚本:
$(document).ready(function(){
$("#mySearchbar").on("keyup", function() {
var value = $(this).val().toLowerCase();
$("#myTable tr:not(.th)").filter(function() {
$(this).toggle($(this).text().toLowerCase().indexOf(value) > -1)
});
});
});
CSS:
tr:nth-child(odd) {
background-color: #CCCCCC;
}
tr:nth-child(even) {
background-color: #FFFFFF;
}
https://stackoverflow.com/questions/56099282
复制相似问题