原生 js----原型链记录

xiaoxiao2021-02-28  47

// function Elem(id){ // this.elem = document.getElementById(id) // } // Elem.prototype.html = function (val){ // var elem = this.elem // if(val){ // elem.innerHTML = val // return this; // }else{ // return elem.innerHTML // } // } // Elem.prototype.on = function (type,fn){ // var elem = this.elem; // elem.addEventListener(type,fn) // return this // } // var div1 = new Elem('div1') //根据实际情况,进行id 的绑定 // // console.log(div1.html()) // div1.html('<p>进行环境测试</p>').on('click',function(){ // alert("测试成功") // }).html("<p>这里是进行返回的值,也就是监听事件的</p>")
转载请注明原文地址: https://www.6miu.com/read-2623141.html

最新回复(0)