随笔分类 - jQuery
摘要:javascript获取光标位置以及设置光标位置在项目开发中经常遇到input等设置光标位置到最后的问题,在IE、Firefox、Opera等主流浏览器的获取光标位置(getCursortPosition)以及设置光标位置(setCursorPosition)的函数。function getCursortPosition (ctrl) {//获取光标位置函数 var CaretPos = 0; // IE Support if (document.selection) { ctrl.focus (); var Sel = document.selection.createRange (); .
阅读全文