原生js仿jquery一些常用方法(必看篇)(2)

//siblings() Object.prototype.siblings = function(){ var chid=this.parentNode.children; var eleMatch = []; for(var i=0,l=chid.length;i<l;i++){ if(chid[i]!=this){ eleMatch.push(chid[i]); } } return eleMatch; } //children() 原生js已含有该方法,故命名为userChildren。 Object.prototype.userChildren = function(){ var chid=this.childNodes; var eleMatch = []; for(var i=0,l=chid.length;i<l;i++){ eleMatch.push(chid[i]); } return eleMatch; } //parent() Object.prototype.parent = function(){ return this.parentNode; } //next() Object.prototype.next = function(){ return this.nextElementSibling; } //prev() Object.prototype.prev = function(){ return this.previousElementSibling; }

jquery事件函数原生js已有,另外,原生js实现jquery的一个常用函数 ajax 将会在下一篇写道。

原生js实现ajax方法

以上就是小编为大家带来的原生js仿jquery一些常用方法(必看篇)的全部内容了,希望对大家有所帮助,多多支持脚本之家~

您可能感兴趣的文章:

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/wzjjww.html