Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Regular Coder
    Join Date
    Jan 2007
    Posts
    217
    Thanks
    9
    Thanked 0 Times in 0 Posts

    Getting attributes from css divs

    Hey there.

    I want to move a div around a page, and I do this by getting the original top and left values of a div, and then change them.

    But the problem is getting the original values; I checked online and thought that this would work:

    Code:
    	var chart = document.getElementById(charDiv).style.top;
    	var charl = document.getElementById(charDiv).style.left;
    	alert('char_t:' + chart + ' char_l:' + charl + 'charDiv:' + charDiv);
    charDiv is passed into the function (its the id of the div I want to move). I know that charDiv has a value by looking at the values of the alert() statement, but the values of chart and charl are empty. The alert simply outputs

    char_t: char_l: charDiv: charOne

    any help would be appreciated

  • #2
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,861
    Thanks
    160
    Thanked 2,223 Times in 2,210 Posts
    Blog Entries
    1
    Try using the function given under "The script" at http://www.quirksmode.org/dom/getstyles.html
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)


  •  

    Posting Permissions

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