htmlloopsif-statementscript-tag

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

  • 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";}