let letterCloseButton = document.querySelector('.letter-close-button') let txtBox = document.querySelector('.txtBox') let focusBorder = document.querySelector('.focus-border') txtBox.focus() function myFunction(x) { if (x.matches) { txtBox.addEventListener("click", () => { document.documentElement.scrollTop = 200 setTimeout(() => { document.documentElement.scrollTop = 200 }, 150); }) } else { console.log("false"); } } var x = window.matchMedia("(max-width: 768px)") // myFunction(x) // x.addListener(myFunction) txtBox.addEventListener('input', (e) => { if (e.target.value === "") { letterCloseButton.style.display = "none" } else { letterCloseButton.style.display = "block" } focusBorder.classList.remove("focus-border") e.target.value = e.target.value.replace(/[^a-zA-Z? ]/g, "") let rangeOfBlankTile = 3 if (rangeOfBlankTile === "") { rangeOfBlankTile = 3 } e.target.value = e.target.value.replace(/ /g, '?') let data = [] data = e.target.value.split('').filter((i) => i === '?') if (data.length > rangeOfBlankTile) { e.target.value = e.target.value.replace(/\?$/, '') } }) letterCloseButton.addEventListener("click", () => { txtBox.value = "" letterCloseButton.style.display = "none" }) const filterInputs = document.querySelectorAll('.filter_val'); Array.from(filterInputs).forEach((item) => { item.addEventListener("input", (e) => { const inputValue = e.target.value; const parentElement = e.target.parentElement; const imgElement = parentElement.querySelector('img'); const tooltipElement = parentElement.querySelector('.filter-tooltip'); if (inputValue == "") { imgElement.src = "/assets/images/questionmark.svg" setTimeout(() => { item.nextElementSibling.setAttribute("data-tip", item.nextElementSibling.id) }, 100); tooltipElement.style.setProperty('--tooltip-padding', '0.5rem'); tooltipElement.style.setProperty('--tooltip-border-style', 'soild'); } else { item.nextElementSibling.removeAttribute("data-tip") imgElement.src = "/assets/images/close-btn.svg" tooltipElement.style.setProperty('--tooltip-padding', '0'); tooltipElement.style.setProperty('--tooltip-border-style', 'none'); } item.nextElementSibling.addEventListener("click", () => { e.target.value = "" imgElement.src = "/assets/images/questionmark.svg" setTimeout(() => { item.nextElementSibling.setAttribute("data-tip", item.nextElementSibling.id) }, 100); tooltipElement.style.setProperty('--tooltip-padding', '0.5rem'); tooltipElement.style.setProperty('--tooltip-border-style', 'soild'); }) }) })