OzzyH Posted October 6, 2022 Share Posted October 6, 2022 Site URL: https://dragonfly-pentagon-ym6h.squarespace.com/ Hi I'm trying to change the search functions throughout my website depending on the page I'm on. So the homepage allows you to search for the whole website, and the events page lets you search for events only. I'm currently using the code <script> window.addEventListener('DOMContentLoaded', changeSearchPlaceholder); function changeSearchPlaceholder() { let newText = "Search Me"; let searchBars = document.querySelectorAll('.search-input'); searchBars.forEach(el => el.placeholder = newText) } </script> in the footer, but that ends up changing every single search box placeholder on the whole website. How do I target a specific one? Link to comment
Solution tuanphan Posted October 8, 2022 Solution Share Posted October 8, 2022 Remove code from Footer Next edit page where you want to change this > Add a Code Block (anywhere on page, except footer) > Add this code <script> window.addEventListener('DOMContentLoaded', changeSearchPlaceholder); function changeSearchPlaceholder() { let newText = "Search Me"; let searchBars = document.querySelectorAll('.search-input'); searchBars.forEach(el => el.placeholder = newText) } </script> OzzyH 1 Email me if you have need any help (free, of course.). Answer within 24 hours. Or send to forum message Contact Customer Care - Learn CSS - Buy me a coffee (thank you!) Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment