jquery自定义类和派生类写法一例

来源:互联网 发布:linq过滤重复数据 编辑:程序博客网 时间:2024/05/20 01:46
/**  *定义:表单控件的js类函数  * vp:hsg  * create date:2015-09  * http://blog.csdn.net/hsg77  *///定义抽象类 基类 表单元素; (function () {    //    $.FormElement = function () {        //var e = $('#' + e_name);        //默认属性值        var m_oid = '';        var m_Name = '';        var m_width = 800;        var m_height = 600;        //属性的获取与设置方法        this.oid = function () {            return m_oid;        };        this.oid_set = function (value) {            m_oid = value;        };        //                this.Name = function () {            return m_Name;        };        this.Name_set = function (value) {            m_Name = value;        };        //        this.width = function () {            return m_width;        };        this.width_set = function (value) {            m_width = value;        };        //        this.height = function () {            return m_height;        };        this.height_set = function (value) {            m_height = value;        };        //添加方法        this.Msg = function (msg) {            alert(msg);        };        return this;    };})(jQuery);//定义js表单对象 FormObject:FormElement 从FormElement基类派生;(function(){    $.FormObject = function () {        var base = new $.FormElement();        //定义属性        //编辑表名        var m_edit_table_oid = '';        this.edit_table_oid = function () {            return m_edit_table_oid;        }        this.edit_table_oid_set = function (value) {            m_edit_table_oid = value;        }        //比例显示        var m_is_scaledisplay = false;        this.is_scaledisplay = function () {            return m_is_scaledisplay;        }        this.is_scaledisplay_set = function (value) {            m_is_scaledisplay = value;        }        //返回函数本身对象与base对象合并体        return $.extend(true,base, this);      };    })(jQuery);//测试类代码var fo = new $.FormObject();fo.oid_set('oid');alert(fo.oid());//alert(fo.height());fo.height_set(1000);alert(fo.height());//fo.edit_table_oid_set('ddsssggg');alert(fo.edit_table_oid());fo.Msg('good');

0 0
原创粉丝点击