TonyKapa Posted June 28, 2022 Share Posted June 28, 2022 Hello! I am trying to do a simple hover event in my cart dropdown menu Code is following var q = document.querySelector("#_desktop_cart"); var a = document.querySelector("#_desktop_cart > div.leo-dropdown-cart.defaultcart.dropdown"); q.addEventListener("mouseover", ()=>{a.classList.add("show")}); q.addEventListener("mouseout", ()=>{a.classList.remove("show")}); It works when I add the code from devtools console but not when I add it put it in javascript files in prestashop (custom.js , header,js) I tried wrapping in it document.ready as well but its not working either. Any way around it ? Thanks in advance! Link to comment Share on other sites More sharing options...
tdsoft Posted June 29, 2022 Share Posted June 29, 2022 11 hours ago, TonyKapa said: Hello! I am trying to do a simple hover event in my cart dropdown menu Code is following var q = document.querySelector("#_desktop_cart"); var a = document.querySelector("#_desktop_cart > div.leo-dropdown-cart.defaultcart.dropdown"); q.addEventListener("mouseover", ()=>{a.classList.add("show")}); q.addEventListener("mouseout", ()=>{a.classList.remove("show")}); It works when I add the code from devtools console but not when I add it put it in javascript files in prestashop (custom.js , header,js) I tried wrapping in it document.ready as well but its not working either. Any way around it ? Thanks in advance! What is your website? Are you sure that your website contain any HTML tag with ID = _desktop_cart or class= div.leo-dropdown-cart.defaultcart.dropdown Link to comment Share on other sites More sharing options...
Ress Posted June 29, 2022 Share Posted June 29, 2022 Did you clear the cache? Both from prestashop, in case you have it active, as well as from the browser? Specifically, you could see in the source of the page, if your code is in the file (custom.js, header.js). Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now