梦想家约瑟夫是对的,它是style.left
。但是您还需要将这些数字转换为Max
函数的整数。这是我的代码,效果很好:
Javascript:
function test() {
var leftOne = document.getElementById('one').style.left;
var leftTwo = document.getElementById('two').style.left;
var leftThree = document.getElementById('three').style.left;
var max123 = Math.max(parseInt(leftThree), parseInt(leftTwo), parseInt(leftOne));
alert(max123);
return false;
}
HTML:
<div id="one" style="left:30px">aaaaa</div>
<div id="two" style="left:22px">bbbbb</div>
<div id="three" style="left:34px">ccccc</div>
<a href="#" onclick="test()">test</a>
结果:34