jquery获取和设置textarea光标位置

var textarea=$("textarea[name=xxx]")

//获取光标位置

var index = textarea.prop("selectionStart");

//设置光标位置

textarea.prop("selectionStart", index);
textarea.prop("selectionEnd", index);

posted @ 2023-06-02 15:38  奇迹之耀  阅读(305)  评论(0)    收藏  举报