NEWS: Total Picture Views: 151536 | Total Article Views: 161054 | Top 5 Most Popular Article: 1. Am I Stuck Algorithm with Becker Robot | 2. PickUpThings with Becker Robot | 3. How to read a JSON and work with it | 4. Encrypted Data GUI (Download .Zip) | 5. Create Wall and Things with Becker

innerHTML Example Javascript

Description:

In this example I will be showing how to change a content in html with Javascript.

Code:

<!DOCTYPE html>
<html>
<head>
    <title></title>
    <style>
        .correct{
            color: greenyellow;
        }
        .incorrect{
            color: #ff0000;
        }
    </style>
</head>
<body>
<div id="test">

</div>
<input type="text" id="input1"> = <input type="text" id="input2">
<br><input type="button" onclick="validate()" value="Verify">



<script type="text/javascript">
function validate() {
var input1 = document.getElementById("input1").value;
var input2 = document.getElementById("input2").value;
console.error("Input1:" + input1);
    if(input1 == input2) {
        document.getElementById("test").innerHTML = "<p class='correct'>Correct!</p>";
    }else{
        document.getElementById("test").innerHTML = "<p class='incorrect'>Incorrect!</p>";
    }

    }
</script>
</body>
</html>
Attachments: None

Tags: innerHTML

Total Views: 904

My name is Jean-Mathieu

I created this website so other people could enjoy finding useful stuff easier. If you have any question do not hesitate to contact me.

jean8mathieuCreated on 01/29/15


affiliate_link

Disclosure: We are a website that needs compensation to operate like any other website on the internet.
We may receive consideration for our reviews but we are totally unbiased and do not accept paid reviews or fake reviews claiming to be something they are not.