首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 其他教程 > 其他相关 >

代码小技艺

2012-08-15 
代码小技巧1、Ext面板中的工具栏tbar里是按钮居右的符号是“-”,分隔符是“-”。?Ext.onReady(function(){var p

代码小技巧

1、Ext面板中的工具栏

tbar里是按钮居右的符号是“->”,分隔符是“-”。

?

Ext.onReady(function(){var panel = new Ext.Panel({             renderTo:"myPanel",          id : "testPanel",          autoWidth  : true,             autoHeight : true,             autoScroll : true,          frame:false,          border : false,          margins : '0 0 0 0',          split : true,             minHeight : 100,             autoHeight : true,           tbar : [{                   iconCls: 'icon-add',                   text : '添加'            },{                iconCls: 'icon-remove',                   text : '移除'            }]          });          panel.tbar.dom.align = 'center';});

2、去除字符串空格,空格出现的位置分别为前中后,下面分别有两种方式处理

?

方式一(无法处理中间的空格)str=str.replace(/(^\s*)|(\s*$)/g,"");//replace(/(^\s*)/g, "") 去左空格//replace(/(\s*$)/g, "") 去右空格方式二(包括中间的空格)function doTrim(str,is_global) { var result; result = str.replace(/(^\s+)|(\s+$)/g,""); if(is_global.toLowerCase()=="g") result = result.replace(/\s/g,""); return result; } 


3、屏蔽文本框的字符键(输入框只接受数字)

?

function checkNumb(){if (event.keyCode < 45 || event.keyCode > 57)  event.returnValue = false;}

?4、javascript call函数的标准解释:call方法是将一个对象的方法在另一个对象的上下文环境中执行

热点排行