0

Trying to add some javascript in a Wordpress DIVI page. I don't understand why the display property of my html elements is not defined as "None"... So it never goes in the "if" statement...

2 buttons /2 Rows / Hide and show function.

When debugging the JS in the developper console, I can see the property is "Block". But the element are clearly hidden on the front and display property is "none".

URL of the page : https://www.mindyourcash.fr/club-option-invest-panel/

CSS

#playlistyt,#downloadsrow
{
  display:none;
}

HTML

<button onclick="ShowForum()">Forum</button>
<button onclick="ShowVideos()">Vidéos</button>

JS

<script>
  function ShowForum() {
  var forum = document.getElementById('forumrow');
     var video = document.getElementById('playlistyt');
    
  if (forum.style.display === "none") {
    forum.style.display = "block";
    video.style.display="none";
  } 
    
  }
    
  function ShowVideos() {
  var forum = document.getElementById("forumrow");
     var video = document.getElementById("playlistyt");
    
if (video.style.display === "none") {
  video.style.display="block";
   forum.style.display = "none";
    
  }
}
</script>
   

Thank you

Paul Martinez
  • 562
  • 1
  • 9
  • 19
  • Duplicate of [Why element.style always return empty in JS?](/q/50645188/4642212). Please, before blindly using `if (forum.style.display === "none")`, _verify_ that `forum.style.display` even is the expected value. – Sebastian Simon Nov 11 '22 at 10:57

0 Answers0