【发布时间】:2020-01-07 18:30:43
【问题描述】:
我正在尝试在我的 HTML 正文中插入脚本:
<body>
<script type="text/javascript" src="myFunction.js"></script>
可能问题出在路径上,但我找不到我的错误,我更改了 100 次,这是我的“myFunction.js”:
function myFunction() {
// Declare variables
var input, filter, table, tr, td, i, txtValue;
input = document.getElementById("myInput");
filter = input.value.toUpperCase();
table = document.getElementById("myTable");
tr = table.getElementsByTagName("tr");
var tamano = 0;
// Loop through all table rows, and hide those who don't match the search query
console.log(tr.length);
for (i = 0; i < tr.length; i++) {
td = tr[i].getElementsByTagName("td")[7];
//console.log(td);
if (td) {
txtValue = td.textContent || td.innerText;
if (txtValue.toUpperCase().indexOf(filter) > -1) {
tamano = tamano +1;
tr[i].style.display = "";
} else {
tr[i].style.display = "none";
}
}
}
var list = document.getElementById("capa"); // Get the <ul> element with id="myList"
list.removeChild(list.childNodes[0]);
console.log(tamano);
var capa = document.getElementById("capa");
var h1 = document.createElement("p");
h1.innerHTML = tamano;
capa.appendChild(h1);
}
你可以在这里看到我的项目文件夹:
你能帮我找出我做错了什么吗?
谢谢!
【问题讨论】:
标签: javascript java html spring netbeans