the answer for all question about Oxygen Builder plugin and WordPress

I need some HELP FROM JAVASCRIPT EXPERTS here, please.

I need some HELP FROM JAVASCRIPT EXPERTS here, please.

What would cause this function to fire on page load? It’s supposed to do that on clicking tabs.

I don’t want the function to fire on page load, but that’s what is happening.

let tabs = document.querySelector(‘.tabs’);

tabs.addEventListener(‘click’, disableScroll);
function disableScroll(){
document.body.style.overflow = ‘hidden’;
console.log(‘scroll disabled’);
};



Source

7 Comments
  1. Alexander van Aken says

    Not a coder here but I guess you need to fire the function. So add disableScroll(); at the end outside of the function.

  2. Rich Deane says

    Is there any code that fires the first tab click on page load, which would then trigger your code? Debug the code, and look at the call stack to see if you you can trace it back…

  3. Maxime Desrosiers says

    Agreed… nothing at all in your code makes the function run on page load, so look elsewhere.

  4. Maxime Beguin says

    Btw I guess you have several elements with the .tabs class. In this case you need to use querySelectorAll. And the result in an array, so you’ll need to loop into the array to create an eventListener for each element.

  5. Albert Nurick says

    I would imagine that a page load would trigger a “click” of the first tab that gets displayed, since this code would typically update the contents of the tab.

  6. Jason Williams says

    You’ll need to post a url or complete source code… this event listener is working fine.

    https://gist.github.com/jasonwilliamsau/5a9976152c81048b9c40e6deb582d2ae

  7. Budi Haryono says

    Did you try prefend?

Leave A Reply

Your email address will not be published.

Oxyrealm Docs