开发者

JavaScript $('myDiv').style.direction always returns blank?

开发者 https://www.devze.com 2022-12-14 02:29 出处:网络
I\'m trying to get the direction property for the element. I have this code: document.write(\'<div style=\"position: absolute; display: none;\" id=\"menuDiv\"></div>\');

I'm trying to get the direction property for the element. I have this code:

document.write('<div style="position: absolute; display: none;" id="menuDiv"></div>');

And in my .css file I have:

#menuDiv {
    direction: rtl;
}

Then, using prototype, I'm trying to query the direction for that div:

alert( $('menuDiv').style.direction );

But for some reason I'm always getting blank, ne开发者_运维知识库ver an 'rtl' value which I need to find out whether current style is left-to-right or not so that the menu can be positioned properly.

Thanks!


Try using $('menuDiv').getStyle('direction'). The element's "style" property may not contain the style as applied by the stylesheet.

0

精彩评论

暂无评论...
验证码 换一张
取 消