JavaScript Program to Swap Two Images

Write a JavaScript program to swap two images.



Source Code
<html>
<head>
    <title>Swap Images</title>
    <script>
        function swapImages()
        {
            var s1 = document.getElementById('img1');
            var s2 = document.getElementById('img2');
            var t = s1.src;
            s1.src = s2.src;
            s2.src = t;
        }
    </script>
</head>
<body>
    <div style="text-align: center;">
        <img src="images/html_dev.png" id="img1" height="150"/>
        <img src="images/js_dev.png" id="img2" height="150"/><br>
        <input type="button" value="Swap Images" onclick="swapImages()">
    </div>
</body>
</html>
Output