我的搜索表有问题。 我使用W3中的代码,此代码用于过滤一列。 有人会这样做,以便一次过滤两列吗?例如,名称和姓氏
func setUpLocalNotification(){
let calendar = NSCalendar(identifier: .gregorian)!
var dateFire = Date()
var fireComponents = calendar.components([NSCalendar.Unit.day,NSCalendar.Unit.month,NSCalendar.Unit.year,NSCalendar.Unit.hour,NSCalendar.Unit.minute], from: dateFire)
fireComponents.year = addAlarm.year
fireComponents.month = addAlarm.month
fireComponents.day = addAlarm.day
fireComponents.hour = addAlarm.hour
fireComponents.minute = addAlarm.minute
dateFire = calendar.date(from: fireComponents)!
let localNotification = UILocalNotification()
localNotification.fireDate = dateFire
localNotification.alertBody = addAlarm.msg
localNotification.soundName = UILocalNotificationDefaultSoundName
localNotification.userInfo = ["Uid" : addAlarm.id]
UIApplication.shared.scheduleLocalNotification(localNotification)
}
代码链接:https://www.w3schools.com/howto/howto_js_filter_table.asp
谢谢!
答案 0 :(得分:2)
您还应该搜索第二个td
。
function myFunction() {
table, tr, td, i; input = document.getElementById("myInput");
filter = input.value.toUpperCase();
table =document.getElementById("myTable");
tr = table.getElementsByTagName("tr");
for (i = 0; i < tr.length; i++) {
td = tr[i].getElementsByTagName("td")[0];
td2 = tr[i].getElementsByTagName("td")[1];
if (td && td2) {
if (td.innerHTML.toUpperCase().indexOf(filter) > -1 || td2.innerHTML.toUpperCase().indexOf(filter) > -1) {
tr[i].style.display = "";
}
else { tr[i].style.display = "none"; }
}
}
}
答案 1 :(得分:0)
您可以使用名为Listjs的简单js框架
http://listjs.com/搜索,排序或过滤数据