I have a problem with jQuery position () code. The code works fine on Chrome / Firefox, but does not work on IE.
JS Code:
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 HTML:
<ul id="menu">
<li class="active"><a href="test.php"><span>Test 1</span></a></li>
<li><a href="test2.php"><span>Test 2</span></a></li>
</ul>
Regular browsers return the left and top values, and IE says:
Message: 'position (). left 'is null or not an object
Thanks in advance.
source
share