• jQuery.focusEnd() 不及格的程序员


    <script>
                                        jQuery.fn.setCursorPosition = function(position)
                                        { 
                                        if(this.lengh == 0) 
                                            return this; 
                                        return $(this).setSelection(position, position); 
                                        } 
                                        jQuery.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;
                                        } 
                                        jQuery.fn.focusEnd = function(){ this.setCursorPosition(this.val().length); }
                                        jQuery("#listBoxWageItem").click(function (e)
                                        {
                                            if (jQuery.trim(jQuery(this).find("option:selected").text()) != "")
                                            {
                                                jQuery("#txtFormula").val(jQuery("#txtFormula").val() + "[" + jQuery.trim(jQuery(this).find("option:selected").text()) + "]").focusEnd();                                            
                                            }
                                        });
                                    </script>
  • 相关阅读:
    Symmetric Order
    Red and Black
    Sticks(递归经典)
    Pascal Library
    cantor的数表
    OJ 调试技巧:VS2010 中 通过设置编译参数定义宏,无需修改源文件重定向标准输入输出
    strcmp
    最短周期串
    字母重排
    codeblocks 单步调试
  • 原文地址:https://www.cnblogs.com/ioriwellings/p/9020272.html
Copyright © 2020-2023  润新知