# How to add simple js to theme \</body\>

**URL:** <https://meta.discourse.org/t/how-to-add-simple-js-to-theme-body/194822>\
**Category:** Development\
**Created:** [June 23, 2021, 6:44pm UTC](https://meta.discourse.org/t/how-to-add-simple-js-to-theme-body/194822 "2021-06-23T18:44:46Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Thorin](https://avatars.discourse-cdn.com/v4/letter/t/96bed5/32.png) [@Thorin](https://meta.discourse.org/u/Thorin)\
**Post date:** [June 23, 2021, 6:44pm UTC](https://meta.discourse.org/t/how-to-add-simple-js-to-theme-body/194822/1 "2021-06-23T18:44:47Z")

</div>

I am trying to add simple javascript to in CSS/HTML edit in Themes.

Effectively the ability to click buttons to expand content with `addEventListener`

```plaintext
<script>
var coll = document.getElementsByClassName("collapsible");
var i;

for (i = 0; i < coll.length; i++) {
  coll[i].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";
    }
  });
}
</script>

```

However, this script doesn’t seem to appear in the source code.

Any help?
