I have a searchbox as below:
<input type="text" class="form-control" onkeyup="myFunction()" id="myInput"/>
and I have a table with id="show_member" with different columns. I have written a code as below and I would like to search all columns whenever I type something in the searchbox(the input above) What is the problem with the code and how can I fix it? Not only doesn't it show the related columns but also it doesn't get removed when I delete all the letters in the search box.
function myFunction(){
var input = document.getElementById("myInput");
//alert(input.value);
var iv = input.value;
var rows = $('table tr').hide().filter(":contains(".'iv'.")").show();
}
thanks for your help in advance
Use +
for string operators (concatenation) in JavaScript
$('table tr').hide().filter(":contains(" + iv +")").show();
instead of
$('table tr').hide().filter(":contains(".'iv'.")").show()
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.