Catching "cursor place change" events inside textareas with jQuery (IE6-compatible)
How can I catch the event of "cursor place change" inside textarea with jQuery (also should working in IE6)?
Example1:
Before :text |
After : te|
Example2:
Before :text |
After : text tex|t2
Example3:
Before :text |
After : |
Edit:
After catching the event of cursor- need also to check if cursor change his position (also have to work for IE6)
Edit2:
If you have solution that will not work in IE6 but in IE7+webkit please w开发者_如何学运维rite it
There are essentially three events that can cause a cursor to change position,
keystrokes
mouse clicks
programmatic events like paste, select, focus...
I would capture those events for whatever it is you are trying to accomplish with 'cursor place change'
code sample added:
$("#myTextInput").bind("keydown click focus", function() {
alert("Current position: " + $(this).caret().start);
});
Thanks to @Nick Craver
I've found that the select event seems to cover all changes to caret position.
精彩评论