开发者

CSS JQuery Position Selector is null on IE

I have a problem with my JQuery position() code. The code works perfectly on Chrome/Firefox but fails on IE.

The JS code is:

function myFunc() {

var x = $("#menu li.active");
if (x == null)
  alert('x is null');
else  
  alert(x.position().left + " " + x.position().top);
}

$(document).ready(function() { myFunc(); });

And the HTML is:

<ul id="menu">
    <li class="active"><a href="test.php"><span>Test 1</span></a></li>
    <li><a href="test2.php"><span>Test开发者_Go百科 2</span></a></li>
</ul>

Normal browsers returns the left and top values, and IE says:

Message: 'position().left' is null or not an object

Thanks in advance.


I found the problem. The HTML header was:

<html dir="rtl">

And that's what caused the problem in my case. When I set to page to LTR it works also on IE.

Thanks.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜