diff --git a/static/js/search.js b/static/js/search.js index 3aa39f4..e286f82 100644 --- a/static/js/search.js +++ b/static/js/search.js @@ -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"); diff --git a/templates/posts.html b/templates/posts.html index d090244..e7dce29 100644 --- a/templates/posts.html +++ b/templates/posts.html @@ -6,7 +6,7 @@ {% block content %}