Click here to Skip to main content
15,891,473 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
My problem is moving an image from right to left and again come to left to right after left margin.
HTML
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title> Javascript Animations: Demo</title>
    <script>
        var x = null;
        function doMove() {
            x.style.right = parseInt(x.style.right) + 1 + 'px';           
            setTimeout(doMove, 20);                  
          
        }
        function init() {
            x = document.getElementById('xobject');
            x.style.right = '10px';
            doMove();           
            
        }
       
        window.onload = init;
        function f1() {
            alert("clicked");
        }
        function f2() {
            document.m1.src = "moon.jpg";
        }
        function f3() {
            document.m1.src = "papy.jpg";
        }
    </script>
</head>
<body>
    <h1> Javascript Animations: Demo</h1>
    <div id="xobject" style="removed:absolute">
        Hello
       <img id="m1" name="m1" src="papy.jpg"  style="margin-left:200px" onclick="f1()" onmouseover ="f2()"  önmouseout ="f3()" />   
    </div>

</body>
</html>
Posted
v4

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900