the answer for all question about Oxygen Builder plugin and WordPress

Where am I going wrong with this JS?

Where am I going wrong with this JS?

// OBJECTIVE: when clicking on .ff-el-form-check which is nested within .home-section-cta, scroll down to #cta-section-1

function scrollToCta() {
var elmnt = document.getElementById(“cta-section-1″);
var object = document.getElementsByClassName(“ff-el-form-check”);
object.onclick = scrollToCta();


  1. Robert Chan says

    getElementsByClassName returns a HTMLCollection [1]
    so when you do object.onclick you’re setting the onclick handler on the array rather than the individual elements with the class ff-el-form-check

    so you’ll have to iterate through all the elements in the object HTMLCollection and set the onclick handler for each one. like shown here:


  2. Gavin McIntosh says

    Hey Alex looks like you are mixing jQuery with vanilla js (which is fine) but you might aswell take advantage of jQuery selectors simply by using $(“.your-selector”) as opposed to document.getElementsByClassName or document.getElementByID.

    To get nested classes just do it how you would in CSS by wrapping $(“”) around it for example:

    $(“.class > .nested-class”)

Leave A Reply

Your email address will not be published.

Oxyrealm Docs