문제

I have the following line of code:

var newLeftPos = $('span#s' + i).position().left - parseInt($('span#s' + i).css('width'), 10);

It works great in ie6 and upwards but I also need to get it to work for ie5.5. (Let's not argue about that now - I know - but I have no option)

I'm certain it falls on the .position() while I'm testing on ie5.5 with jquery 1.2

How could I do the same in plain javascript? Could "offsetParent" help me here? Apparently ie5.5 supports that.

Thanks in advance.

도움이 되었습니까?

해결책

You are looking for offsetParent, offsetLeft and offsetRight.

As you can see in the link, looks like they are supported even by old granny IE5.5.

Check this text page to see if they are really supported by your browser first.

Then your function should be something like

var span = document.getElementById('s' + i);

var newLeftPos = span.offsetWidth - parseInt(span.style.width);
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top