Javascript Button Hover works only once

I’m trying to implement some button which displays list items on hover.

It works good however it stops working after the first hover then I need to keep refreshing the page for it to work again.

Please see the code below;

var btn = document.getElementsByClassName("collapsible"); 
            
                    btn[0].addEventListener("click", function () { 
                        this.classList.toggle("active"); 
                        var content = this.nextElementSibling; 
                        if (content.style.display === "block") { 
                            content.style.display = "none"; 
                        } else { 
                            content.style.display = "block"; 
                        } 
                    }); 

Is there anyway I can make it work again and again without having to refresh the page?

67 thoughts on “Javascript Button Hover works only once”

  1. Pingback: viagra connect
  2. Pingback: buy cialis pills
  3. Pingback: sildenafil 20mg
  4. Pingback: cheapest viagra
  5. Pingback: viaga
  6. Pingback: how to take cialis

Leave a Comment