js的小用法

    alert('2008-01-02'.replace(/-0(\d)-0(\d)/, '年$1月$2日'));
            var ff = new asd();
            alert(ff.it1);
            function asd() { this.it1 = "aa"; }
            asd.prototype.ff1 = function () { alert("bb") }
            ff.ff1();//调用方法不能放在方法定义前面,不然报错误: 对象不支持此属性或方法

 

    Ext移动下拉元素小方法:

    var selectName = new Ext.Button({
                text: '选择',
                style: 'margin:10,10,5,10',
                handler: function (e) {
                    var s = $('#ctl00_ContentPlaceHtml_ddlSName option:selected');
                    var s2 = $('#ctl00_ContentPlaceHtml_ddlSNameSelected option');
                    for (var i = 0; i < s.length; i++) {
                        for (var j = 0; j < s2.length; j++) {
                            if (s2[j].value == s[i].value) {
                                Ext.Msg.alert('提示', s[i].text + '已存在,不能选择');
                                return false;
                            }
                        }
                        var option = new Option(s[i].text, s[i].value);
                        document.getElementById('ctl00_ContentPlaceHtml_ddlSNameSelected').options.add(option);
                    }
                },
                renderTo: 'selectName'
            });
            var selectNameDelete = new Ext.Button({
                text: '删除',
                style: 'margin:5,10,10,10',
                handler: function () {
                    var s = $('#ctl00_ContentPlaceHtml_ddlSNameSelected option:selected');
                    for (var i = s.length - 1; i >= 0; i--) {
                        document.getElementById('ctl00_ContentPlaceHtml_ddlSNameSelected').options.remove(s[i].index);
                    }
                },
                renderTo: 'selectName'
            });

Google
Google Maps
WikipediA
Twitter

你可能感兴趣的:(js)