'Adding HTML in a if-statement

I want the html to open when the password is right and I have tried .js, document.write, .html, href, div, document.getElementById and nothing is working when it's inside the if condition but I need it in there so it opens when the condition is right.

<script>
function 123()
{
var pass=document.getElementById("pass").value;
if(pass=="password")
 {
   alert("Logged In");
   here is where the HTML code should go;
 }
}
</script>


Solution 1:[1]

You can create the html element in this page and give this element display none and when the password is correct change display example:

    if(pass=="password") { 
alert("Logged In"); 
document.getElementById("page").style.display="block";}

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Mohamad Al Zohbie