Hi.wz通过本文主要向大家介绍了鼠标焦点事件,鼠标焦点,鼠标焦点宏,鼠标焦点丢失,鼠标失去焦点事件等相关知识,希望对您有所帮助,也希望大家支持linkedu.com www.linkedu.com
经测试,兼容IE8
//设置焦点相关---begin //用法:$("#txtInput").val("你好").focusEnd(); $.fn.setCursorPosition = function (position) { if (this.lengh == 0) return this; return $(this).setSelection(position, position); } $.fn.setSelection = function (selectionStart, selectionEnd) { if (this.lengh == 0) return this; input = this[0]; if (input.createTextRange) { var range = input.createTextRange(); range.collapse(true); range.moveEnd('character', selectionEnd); range.moveStart('character', selectionStart); range.select(); } else if (input.setSelectionRange) { input.focus(); input.setSelectionRange(selectionStart, selectionEnd); } return this; } $.fn.focusEnd = function () { if (this.val() != undefined) { this.setCursorPosition(this.val().length); } } //设置焦点相关---end</div>
以上就是本文的全部内容,希望本文的内容对大家的学习或者工作能带来一定的帮助,同时也希望多多支持!