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 () { 
                        var content = this.nextElementSibling; 
                        if ( === "block") { 
                   = "none"; 
                        } else { 
                   = "block"; 

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

Read more here:

Content Attribution

This content was originally published by Min Kyung Kwon at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: