Float a div on a textarea?

Posted by Pradeep on Stack Overflow See other posts from Stack Overflow or by Pradeep
Published on 2012-10-17T04:43:40Z Indexed on 2012/10/17 5:01 UTC
Read the original article Hit count: 76

Filed under:
|

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;
}

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about jQuery