From 5031ed847abc10ff5d6b91b847bfe36b65281faa Mon Sep 17 00:00:00 2001 From: Jorge Rivas <97417231+J0rgeR1vas@users.noreply.github.com> Date: Sun, 5 Feb 2023 14:50:28 -0600 Subject: [PATCH] Update script.js --- script.js | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/script.js b/script.js index 4ff64c9..c11361e 100644 --- a/script.js +++ b/script.js @@ -1,4 +1,4 @@ -///text to search code +///text to search function search() { let textToSearch = document.getElementById("text-to-search").value; let paragraph = document.getElementById("paragraph"); @@ -10,7 +10,7 @@ function search() { paragraph.innerHTML = paragraph.textContent.replace(pattern, match => `${match}`) } -///sticky header code +///sticky header window.onscroll = function () {myFunction()}; @@ -25,3 +25,14 @@ function myFunction() { } } + +//search book function in main page + +function searchBook() { + var bookName = document.getElementById("text-to-search").value.toLowerCase(); + if (bookName === "the alchemist") { + window.location.href = "alchemist.html"; + } else if (bookName === "life of pi") { + window.location.href = "lifeofpi.html"; + } + }