jquery银行电子账单表格填入和编辑插件

jquery银行电子账单表格填入和编辑

前段时间做的一个银行表格账单的jquery插件,用于金额写入和编辑的应用,希望对大家有所帮助,发现问题欢迎回复
;(function($){
         function getNum(num) {
                num += '';
                var num1 = num.replace(/[^0-9|\.]/g, '0');//清除字符串中的非数字非.字符  
                if (/^0+/) //清除字符串开头的0  
                    num1 = num1.replace(/^0+/, '');
                if (/^\./.test(num1)) //字符以.开头时,在开头添加0  
                    num1 = '0' + num1;
                num1 = new Number(num1);
                num1 = num1.toFixed(2);//四舍五入保留最后两位数
                return num1;
         }
        $.fn.trSet=function(options){
                var options=$.extend(this,options);
                this.each(function(){
                        var _this=$(this);
                        _this.find(options.trCom).on(options.elemType,function(){
                                var _thisTrTd=$(this).find(options.trTd),
                                _trTdPop=$(this).find(options.trTdPop),
                                _trTdPicTxt=_trTdPop.find(options.trTdPicTxt),
                                _thisTdText=_thisTrTd.text();

                                _thisTdText=$.trim(_thisTdText);
                                _thisTdText=getNum(_thisTdText),
                                _thisTop=$(this).position().top,//当前tr距离父窗体距离
                                _thisW=$(this).width()-5,
                                _thisH=$(this).height()-5;
                                _trTdPicTxt.val(_thisTdText/100); //调用数据处理函数
                                _trTdPop.css({"display":"block","position":"absolute","top":_thisTop,"left":"0"});
                                _trTdPicTxt.css({"width":_thisW,"height":_thisH});
                                _trTdPicTxt.on(options.elemType,function(){return false});
                                _trTdPicTxt.trigger("focus");
                                _trTdPicTxt.blur(function(){
                                        var _thisVal=$(this).val();
                                        _thisVal=getNum(_thisVal);//调用数据处理函数
                                        _thisVal=_thisVal.split("");
                                        _thisVal.splice($.inArray(".",_thisVal),1);//去掉小数点
                                        _thisTrTd.text("");
                                        var j=parseInt(_thisTrTd.length-_thisVal.length);
                                        for(var i=0;i<_thisVal.length;i++){//数据填入单元格,位数匹配
                                                _thisTrTd.eq(j+i).text(_thisVal[i]);
                                        }
                                        _trTdPop.css("display","none");
                                })
                        })                return this;
                })
        }
})(jQuery);

        $(function(){
                $("#getMoney").trSet({
                        trCom:".trCom",
                        trTd:".tdNum",
                        trTdPop:".pupTxt1",
                        trTdPicTxt:".picTxt",
                        elemType:"click"
                });
        
        })

  

亿