Friday 28 November 2014

Swaping two images using JavaScript

<html>
<head>
<script>
 function swap1()
 {
  var txt1 = document.getElementById("img1");
  var txt2 = document.getElementById("img2");
  var txt = txt1.src;
  txt1.src = txt2.src;
  txt2.src = txt;
 }
</script>
</head>

<body>
<img src="DennisRitchie.jpg" id="img1" height="255" />
<img src="BrendanEich.jpg" id="img2" height="255" />
<br /><input type="button" value="Swap images" onclick="swap1()" />
</body>
</html>

for more http://makeitsimple.co.in/js_swapimages.php

Monday 24 November 2014

Program to Display Digital clock using Javascript

<html>
<head>
<title>Digital Clock</title>
<style>
#clock{
 color:#F0F;
}
</style>
</head>
<body>
<script>
function digclock()
{
 var d = new Date()
 var t = d.toLocaleTimeString()
 
 document.getElementById("clock").innerHTML = t
}

setInterval(function(){digclock()},1000)
</script>
Digital Clock
<div id="clock">

</div>
</body>
</html>

for more http://makeitsimple.co.in/js_programs.php