我设置搜索,以便我可以按照我的注释标题进行搜索,但我也希望通过function calc() {
//Gather columns in arrays
var col5 = document.getElementsByClassName('col5');
var col6 = document.getElementsByClassName('col6');
//Start sums at 0
var sum5 = 0, sum6 = 0;
//Loop through each column and add up sums
for(var i = 0; i < col5.length; i++) {
sum5 += parseInt(col5[i].innerHTML);
}
for(var i = 0; i < col6.length; i++) {
sum6 += parseInt(col6[i].innerHTML);
}
//Store sums in total fields
document.getElementById('total5').innerHTML = sum5;
document.getElementById('total6').innerHTML = sum6;
}
进行搜索!
subtitle
我如何在我现在的代码中实现它?
感谢您的帮助!
答案 0 :(得分:2)
您也可以通过字幕进行搜索:
func updateSearchResults(for searchController: UISearchController) {
guard let mapView = mapView,
let searchBarText = searchController.searchBar.text else { return }
matchingItems = self.mapView!.annotations.filter { annotation -> Bool in
if annotation.title!.range(of: searchBarText, options: .caseInsensitive) != nil {
return true
}
if annotation.subtitle!.range(of: searchBarText, options: .caseInsensitive) != nil {
return true
}
return false
}
self.tableView.reloadData()
}