一个贴近实际开发原型链继承的l例子

function DomElement(id){
    this.dom = document.getElementById(id);
}
DomElement.prototype.html = function (val){
    var ele = this.dom
    if (val) {
        ele.innerHTML = val
        return this
    }else{
        return ele.innerHTML
    }
}
DomElement.prototype.on = function (type,fn){
    vae ele = this.dom
    ele.addEventListener(type,fn)
    return this
}
var div1 = new DomElement('div1')
console.log(div1.html());
div1.html('<p>这是一段文字</p>').on('click',function(){
    console.log('clicked')
})
上一篇:Sys.UI.DomElement


下一篇:解决ArcGIS10.1符号化里面没有显示Color Ramp颜色带