www.webdeveloper.com
Results 1 to 3 of 3

Thread: moving a div with javascript

  1. #1
    Join Date
    Sep 2003
    Posts
    1

    moving a div with javascript

    How can I move a div element with javascript?

    I can do this:
    document.all["tussen"].style.top= 200

    so it moves to 200, but what I want is to move it 200 pxs down. I want to do something like this:
    document.all["tussen"].style.top+= 200
    or
    document.all["tussen"].style.top= document.all["tussen"].style.top + 200
    or
    var temp = document.all["tussen"].style.top
    document.all["tussen"].style.top = (temp+200)

    but these things dont work..

    any id's?

  2. #2
    Join Date
    Dec 2002
    Location
    Calgary, Canada
    Posts
    6,123
    try the link below,its actually allot better solution since it will work with most browsers that has JS enabled.

    http://www.webapplikations.com/pages...DivScroll.html
    Cheers

    Khalid

    Message Posting Guidelines In These Forums, Please read these before posting any question.
    Web site: webapplikations.com
    Web Resources Page:Web Resources

  3. #3
    Join Date
    Apr 2003
    Location
    Netherlands
    Posts
    21,654
    top returns a string - it doesn't recognise if it's px or %
    X-browser:
    var t=parseInt(document.getElementById('tussen').style.top);
    document.getElementById('tussen').style.top=t+200+"px";

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles