<!DOCTYPE html><html><body><h2>My First JavaScript</h2><buttontype="button"
onclick="document.getElementById('demo').innerHTML = Date()">
Click me to display Date and Time.</button><pid="demo"></p></body></html>
<!DOCTYPE html><html><body><h2>What Can JavaScript Do?</h2><pid="demo">JavaScript can change HTML content.</p><buttontype="button" onclick="document.getElementById('demo').innerHTML = 'Hello JavaScript!'">Click Me!</button></body></html>
JavaScript Can Change HTML Attribute Values
<!DOCTYPE html><html><body><h2>What Can JavaScript Do?</h2><p>JavaScript can change HTML attribute values.</p><p>In this case JavaScript changes the value of the src (source) attribute of an image.</p><buttononclick="document.getElementById('myImage').src='pic_bulbon.gif'">Turn on the light</button><imgid="myImage" src="pic_bulboff.gif" style="width:100px"><buttononclick="document.getElementById('myImage').src='pic_bulboff.gif'">Turn off the light</button></body></html>