Code Explaining what Javascript can do.

Uncategorized
<!DOCTYPE html>
<html>
<body>

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

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

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

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

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

</tr>

</br></br></br>

<button onclick="document.getElementById('myImage').src='http://www.w3schools.com/js/pic_bulbon.gif'">Turn on the light</button>

<img id="myImage" src="http://www.w3schools.com/js/pic_bulboff.gif" style="width:100px">

<button onclick="document.getElementById('myImage').src='http://www.w3schools.com/js/pic_bulboff.gif'">Turn off the light</button>

</body>
</html>
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.

 

Advertisements

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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 )

w

Connecting to %s