02.The power of JavaScript-2

by Aruna Sanjeewa

HTML

<!DOCTYPE html>
<html>
<body>
<h2>02.The power of JavaScript-2</h2>
<h3>Change HTML attibute.</h3>

<p id="para">JavaScript can change HTML attributes of an element .This example change the src(source) of image element. </p>

<button onclick="document.getElementById('myImage').src='https://d30y9cdsu7xlg0.cloudfront.net/png/172056-200.png'">Correct</button>

<img id="myImage" src="https://d30y9cdsu7xlg0.cloudfront.net/png/172056-200.png" style="width:100px">

<button onclick="document.getElementById('myImage').src='http://icon-icons.com/icons2/834/PNG/512/cancel_circle_icon-icons.com_66723.png'">Incorrect</button>

</body>
</html>