Skip to content

shovon/jquery-caretpixelpos

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

jquery-caretpixelpos

A jQuery plugin to determine the pixel position of a caret.

How to Use

Let's say you wanted to grab the caret position of a textbox everytime the user clicks it. This is how you would do it.

$(function () {
    var textarea = $('#text_area');
    textarea.click(function () {
        var pos = textarea.caretpixelpos();
        console.log("X: " + pos.left);
        console.log("Y: " + pos.top);
    });
    $('#text_area').caretpixelpos();
});

Note

Please note that calling the caretpixelpos adds a positioner property to the jQuery object that it was called on.

Acknowledgement

All thanks goes to @kir, for the wonderful piece of code that actually allows us to grab the caret position. You can check out the original work over at his repository, js_cursor_position

About

A plugin to determine the pixel position of a caret.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages