简体   繁体   中英

How can I make a JavaScript 'if' statement that connects to HTML?

I am trying to make an HTML and a JavaScript code so that after the alert(); function, then the HTML code will run.

Here is my JavaScript code:

alert("Website showing in 3, 2, 1");

And after the person clicks okay from the alert box, then my HTML code will run. How do I make the HTML code run after the JavaScript code?

  1. Put your html content inside a div with class='mydiv' id='div1'
  2. Add some css to hide your div, eg .mydiv { display:none; } .mydiv { display:none; }
  3. After alert() , remove mydiv class from your div:

    document.getElementById('div1').classList.remove('mydiv');

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM