Move object using javascript - Web Development
95 Views

Move object using javascript

imgObj.style.left = ‘0px’; It is used to set object at left side with zero px .

imgObj.style.left = ‘100px’; If you set 100px; then it will leave 100px from left side

imgObj = document.getElementById(‘img’); imgObj is a variable and storing img id ( id = “img”)

function moveRight()
{
imgObj.style.left = parseInt(imgObj.style.left) + 100 + ‘px’;
} // I Called this function to onClick event of input button

If you run this code

JavaScript Move right left Animation

Click button below to move the image to right

Leave a Reply

Your email address will not be published. Required fields are marked *