Change event listener init
This commit is contained in:
parent
c19dbf3e44
commit
f0571e9e38
@ -1,4 +1,4 @@
|
||||
function filter_name(str)
|
||||
function filter_title(str)
|
||||
{
|
||||
if (str.length == 0) {
|
||||
articles.forEach(article => article.style.display = "block");
|
||||
@ -7,5 +7,9 @@ function filter_name(str)
|
||||
}
|
||||
}
|
||||
|
||||
const search = document.querySelector("input[type='search']");
|
||||
const form = document.querySelector("form");
|
||||
let articles = Array.from(document.querySelectorAll("article"));
|
||||
document.querySelector("#search").style.display = "inline-block";
|
||||
|
||||
search.addEventListener("input", () => filter_title(search.value));
|
||||
window.addEventListener("load", () => search.style.display = "inline-block");
|
||||
|
@ -6,7 +6,7 @@
|
||||
|
||||
{% block content %}
|
||||
<h1>{{ section.title }}</h1>
|
||||
<input id="search" class="search" type="text" placeholder="Search titles" oninput="filter_name(this.value)">
|
||||
<input class="search" type="search" placeholder="Search">
|
||||
{{ macros::list_posts() }}
|
||||
{% endblock content %}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user