Collapsible button inside a ul list does work in jsfiddle but not in WP

enter image description here

I implemented a collapsible button, it works well in WP, but if I insert it in a ul list it doesn’t work, that is the button does not open.

Then I tried to run the code in jsfiddle and there it does work.

The only difference between the WP code and the jsfiddle code is in the javascript

  • on WP the var content is defined by this.parentElement.nextElementSibling;
  • on jsfiddle the var content is defined by this.nextElementSibling;

This is due to the fact that

  • by removing parentElement on WP the button will break
  • by adding parentElement on jsfiddle the button will break

Just for information, the javascript on WP is loaded in the footer.

Is it possibile to fix the problem? Here is the jsfiddle demo.

Below you can see jsfiddle vs WP

Read more here:: Collapsible button inside a ul list does work in jsfiddle but not in WP

Leave a Reply

Your email address will not be published. Required fields are marked *