간단한 검색 메뉴가 있습니다.HTML 페이지를로드 한 후 테이블을 숨기려면 클릭시 테이블 표시
페이지로드 후 테이블을 숨기고 싶습니다. 쿼리 할 때 테이블 (검색 결과 표시)을 표시하고 싶습니다.
다른 리소스를 보았지만 시도했지만 실패했습니다.
감사
<script>
function myFunction() {
var input, filter, 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")[3];
if (td) {
if (td.innerHTML.toUpperCase().indexOf(filter) > -1) {
tr[i].style.display = "";
} else {
tr[i].style.display = "none";
} } } }
</script>
<input type="search" id="myInput" onkeyup="myFunction()">
<input type="submit" name="cari" value=" ">
<table border="1px" id="myTable">
<tr class="header">
<th style="width:15%;">Kode Prov</th>
<th style="width:30%;">Prov</th>
<th style="width:15%;">Kode Kab</th>
<th style="width:40%;">Kab</th>
</tr>
<tr>
<td>11</td>
<td>Aceh</td>
<td>01</td>
<td>Aceh Tenggara</td>
</tr>
<tr>
<td>11</td>
<td>Aceh</td>
<td>02</td>
<td>Simeulue</td>
</tr>
</table>