Image Position by & style.left

Image style left and style top We can assign coordinates to position an image by changing its style.left and property value in JavaScript. We can keep changing these values to move the image to different location. Here is the code to set these values.
By using above concepts we will try to change position of an image by moving it from left to right , top to down and vice-versa.
Demo of moving image
The code is here
<title>Demo of Image position and style.left </title>
<link rel="stylesheet" href="../images/all11.css" type="text/css">
<script language='JavaScript' type='text/JavaScript'>
function move_img(str) {

case "down":
document.getElementById('i1') + "px";

case "up":
document.getElementById('i1') + "px";

case "left":
document.getElementById('i1').style.left=200 + "px";

case "right":
document.getElementById('i1').style.left=800 + "px";

<img src=images/help.jpg id='i1' 
 style="position:absolute; left: 500; top: 100;">
<input type=button onClick=move_img('up') value='Up'>
<input type=button onClick=move_img('left') value='Left'>
<input type=button onClick=move_img('right') value='right'>
<input type=button onClick=move_img('down') value='down'>

Image Object offsetLeft & offsetTop of Image Movement of image by button click


* indicates required
Subscribe to plus2net

    More on JavaScript Image Object
    Image SlideShow Script using navigational buttons
    Image Loading to cache while page load by Image object
    Reloading the image without refreshing the page
    Image Rotator Script for automatic Slideshow
    Image Move across by button click
    Image Move continuously across screen
    Image offSetLeft and offSetTop to get position of the image from left and top
    Image Position : Positioning an image by assigning value to and style.left
    Image width: Managing width of the image
    Image height: managing height of the image
    Image align: Image align left or right
    Image border: adding and removing border from Image
    Image alt: updating or reading alt message of image
    krati jain


    I feel this is a good effort
    krati jain
    vitthal chandane


    i fill that it is nice solution which i help to solve my problem.

    Post your comments , suggestion , error , requirements etc here

    We use cookies to improve your browsing experience. . Learn more
    HTML MySQL PHP JavaScript ASP Photoshop Articles FORUM . Contact us
    ©2000-2022 All rights reserved worldwide Privacy Policy Disclaimer