Jump to content

Get A Style Attribute


Guest cfican

Recommended Posts

I'd like to be able to get the style.left value. I can set the left edge of an element with

document.getElementById(obj).style.left = 15px

how can I get the current value?

Link to comment
Share on other sites

You can read the property:

alert(document.getElementById(obj).style.left);

Keep in mind that unless you've actually set the style attribute of the element, the property will be empty. It doesn't obtain the style that was given through the stylesheet.But rather than finding the style property, if you want to check the position use offsetLeft and offsetTop:

alert(document.getElementById(obj).offsetLeft);

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...