vendredi 6 avril 2018

Why won't my button do the function when I click it it. It should toggle the text

function

<button onclick="myFunction()">Try it</button>
          <div id="myDIV">

This is my DIV element.

    </div>


function myFunction() {
var x = document.getElementById("myDIV");
if (x.style.display === "none") {
    x.style.display = "block";
} else {
    x.style.display = "none";
   }
}

I found this code on W3Schools and replaced "myDIV" with "h3" so I can change the text in my header

    <div class="speech-buble-top"><h3 id="h3"> Happy Birthday Tiffany!</h3></div>

Aucun commentaire:

Enregistrer un commentaire