开发者

CSS JQuery Position Selector is null on IE

开发者 https://www.devze.com 2023-02-06 20:14 出处:网络
I have a problem with my JQuery position() code. The code works perfectly on Chrome/Firefox but fails 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

精彩评论

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