Code Explaining what Javascript can do.

<!DOCTYPE html>

<h1>What Can JavaScript Do?</h1>

<p id="demo">JavaScript can change HTML content.</p>
<button type="button" onclick="document.getElementById('demo').innerHTML = 'Hello JavaScript!'">Inner Text Change!</button>

<button type="button" onclick="document.getElementById('demo').style.fontSize='35px'">CSS Change!</button>

<button type="button" onclick="document.getElementById('demo').style.display='none'">Hide!</button>

<button type="button" onclick="document.getElementById('demo').style.display='block'">Show!



<button onclick="document.getElementById('myImage').src=''">Turn on the light</button>

<img id="myImage" src="" style="width:100px">

<button onclick="document.getElementById('myImage').src=''">Turn off the light</button>

The Code written above demonstrates how JavaScript can be used to control the structure(HTML) and Style(CSS) of a webpage.

Copy and Paste this code in your system. Save the file as jstest.html. Run this code in the browser.

For some reason if the internet is not available,use the following images for offline view.



Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s