我如何读取当前影响不一定是样式的元素的任何属性?其中一个属性是“dir”。
最佳答案
最近遇到了类似的问题,可以通过window.getComputedStyle获取元素的属性和 element.currentStyle方法:
var elem = document.getElementById('test');
if (window.getComputedStyle) { // all browsers
cs = window.getComputedStyle(elem, null).getPropertyValue('direction');
} else {
cs = elem.currentStyle.direction; // IE5-8
}
alert(cs);
关于javascript - 如何检测当前网页或元素方向(rtl/ltr)或 javascript 中的任何其他属性?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16957533/