jeudi 24 septembre 2015

How to add an image with an if statement

Is there a way to have an image appear when a certain phrase is typed into an input using an if statement? This is my code

<script type="text/javascript">

    document.getElementById("button").onclick=function() {

        var ask=document.getElementById("ask").value.toLowerCase(); ;
        if (ask =="how tall are the pyramids") {

            document.getElementById("spanId").innerHTML = "146.5 meters";

        } else if (ask== "how tall is the gateway arch") {

            document.getElementById("spanId").innerHTML = "630 feet";

        }

Aucun commentaire:

Enregistrer un commentaire