javascript - Get offsetTop & IE -
I'm trying to get offsetTop in IE but it just does not work as I want.
var miniMap = $ ('# mapMap'), parnts = miniMap.parents (), l = parnts.length, i, setVpos, setHPos = $ ('# showMap'). Event (). Left; (I = 0; i & lt; l; i + = 1) {if (purnits [i] .className === 'small box') {if (isIE) {setVpos = parnts [i] .offsetTop; // incorrect value} other {setVpos = parnts [i] .offsetTop; // should work like}}}
As I can see that I am using jQuery, I could definitely use jQuery offset / status (). Top & amp; Amp; .each:
parnts.each (function () (if ($ (this) .hasClass ('small box')) {setVpos = $ (this) .position (). Top; } ....
.. But, I have heard that "little" is too slow to use for loop. Besides, I'm really curious and would like to know that What you guys used to do before JQuery: -)
My problem is that when I am doing one for loop, I can not use jQuery's obj => status ().
I have googled and Find the following:
document.getElementById ("elementID"). OffsetLeft // All other documents. All.elementID.offsetLeft // IE only
me It seems that this might work:
if (isIE) {setVpos = document.all.parnts [i] .offsetTop;}
. But it was not. So now I am asking people for help from you.
Any suggestions? Thanks in advance!
If you obviously have a reference to the jQuery library, then why you are not using get offset for? Using JQuery, you should not need any variables such as isiE
. The biggest advantage of using the library is cross-browser compatibility. Here's how you can do it ...
var off = $ (parnts [i]) offset () ; Warning (off.top);
Comments
Post a Comment