-4

enter image description here

I have a div which has this list of suggestions. But i need to allocate it at the caret position of the textarea. Is this possible if yes, help me to do it.

function findOffsetPosition(obj) {
    var posX = obj.clientLeft; var posY = obj.clientTop;
    while (obj.offsetParent) {
        if (obj == document.getElementsByTagName('body')[0]) { break }
        else {
            posX = posX + obj.offsetParent.offsetLeft;
            posY = posY + obj.offsetParent.offsetTop;
            obj = obj.offsetParent;
        }
    }
    var posArray = [posX, posY]
    return posArray;
}
4

1 回答 1

-3

这是一个可以帮助您入门的帖子

https://stackoverflow.com/a/7745998/1354978

而这家伙的jsfiddle作品+1

http://jsfiddle.net/gilly3/6SUN8/

于 2012-10-17T04:59:30.770 回答