[英]Javascript open tag not working?
https://pastebin.com/M21NAE2P https://pastebin.com/M21NAE2P
<script>
// get input element
let filterInput = getElementById('filterInput');
// add event listenter
filterInput.addEventLister('keyup', filterNames);
function filterNames(){
console.log(1);
}
</script>
The tag isn't being colored by the IDE and its not working when i run it either. 该标签没有被IDE着色并且在我运行它时也无法正常工作。 Is it atom?
是原子吗? or is it something that i can fix.
还是我可以解决的问题。
You have closed the <input>
tag in your markup. 您已经关闭了标记中的
<input>
标记。 In HTML, the <input>
tag has no end tag. 在HTML中,
<input>
标记没有结束标记。 You also cannot nest <li>
's (which I noticed you have done) 您也不能嵌套
<li>
的(我注意到您已经完成了)
Also, change: 另外,更改:
let filterInput = getElementById('filterInput');
to 至
let filterInput = document.getElementById('filterinput');
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta http-equiv="X-UA-Compatible" content="ie=edge"> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/materialize/0.99.0/css/materialize.css"> <title>My Contacts</title> </head> <body> <div class="container"> <h1 class="center-align"> My contacts </h1> <input type="text" id="filterinput" placeholder="Search Names"> <ul id="names" class="collection with-header"> <li class="collection-header"> <h5>A</h5> </li> <li class="collection-item"> <a href="#">Abe</a> <a href="#">Adam</a> <a href="#">Alan</a> <a href="#">Anna</a> <li class="collection-header"> <h5>B</h5> </li> <li class="collection-item"> <a href="#">Beth</a> <a href="#">Beth</a> <a href="#">Bill</a> <a href="#">Bob</a> <li class="collection-header"> <h5>C</h5> </li> <li class="collection-item"> <a href="#">Carry</a> <a href="#">Cortany</a> <a href="#">Crapy</a> <a href="#">Cheese</a> </li> </ul> </div> <script> // get input element let filterInput = document.getElementById('filterinput'); // add event listenter filterInput.addEventLister('keyup', filterNames); function filterNames() { console.log(1); } </script> </body> </html>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.