<input type="text" id="myInput" onkeyup="myFunction()" placeholder="Search for names.." title="Type in a name">
<table id="myTable" border="1">
<tr class="header">
<th style="width:60%;">Name</th>
<th style="width:40%;">Country</th>
</tr>
<tr>
<td>Alfreds Futterkiste</td>
<td>Germany</td>
</tr>
<tr>
<td>Berglunds snabbkop</td>
<td>Sweden</td>
</tr>
<tr>
<td>Island Trading</td>
<td>UK</td>
</tr>
<tr>
<td>Koniglich Essen</td>
<td>Germany</td>
</tr>
<tr>
<td>Laughing Bacchus Winecellars</td>
<td>Canada</td>
</tr>
<tr>
<td>Magazzini Alimentari Riuniti</td>
<td>Italy</td>
</tr>
<tr>
<td>North/South</td>
<td>UK</td>
</tr>
<tr>
<td>Paris specialites</td>
<td>France</td>
</tr>
</table>
function myFunction() {
var input, filter, table, tr, td, i;
input = document.getElementById("myInput");
filter = input.value.toUpperCase();
table = document.getElementById("myTable");
var rows = table.getElementsByTagName("tr");
for (i = 0; i < rows.length; i++) {
var cells = rows[i].getElementsByTagName("td");
var j;
var rowContainsFilter = false;
for (j = 0; j < cells.length; j++) {
if (cells[j]) {
if (cells[j].innerHTML.toUpperCase().indexOf(filter) > -1) {
rowContainsFilter = true;
continue;
}
}
}
if (! rowContainsFilter) {
rows[i].style.display = "none";
} else {
rows[i].style.display = "";
}
}
}
Code Example |
---|
Html :: html submit form onclick |
Html :: font awesome dropdown icon |
Html :: route link prop vue |
Html :: negrita html |
Html :: html video disable controls |
Html :: changing text colour in html |
Html :: How to generate a QR code in JavaScript? |
Html :: index.html |
Html :: ouvrir dans nouvelle page html |
Html :: index.html favicon.ico 404 (Not Found) |
Html :: phone html |
Html :: html date selector |
Html :: image html |
Html :: how to add lazy loading in html |
Html :: html datetime-local format dd/mm/yyyy |
Html :: fa icon person |
Html :: html prevent focus on input |
Html :: jsonplaceholder with delay |
Html :: how to use html shortcuts |
Html :: whatsapp href link code |
Html :: html lien téléphone |
Html :: ngfor display in html table |
Html :: image size |
Html :: accordion bootstrap 5 collapse not working |
Html :: placeholder text html |
Html :: twig map |
Html :: sub html |
Html :: agregar texto debajo de una imagen html |
Html :: omega ruby |
Html :: select all text of input onclick |