How jquery consonant syntax implements _jquery

Source: Internet
Author: User
I want to be familiar with JavaScript is not do not know jquery, as a leading JavaScript framework, many of his features are exciting, which has to mention the unique consonant writing grammar, then he is only how to achieve it, we also come to achieve a bar.
Copy Code code as follows:

Sx.$=function (ID) {
var t= (typeof (id) = = "string" document.getElementById (ID): ID);
T.text=function () {
Return This.innertext?this.innertext:this.innerhtml.replace (//<.*?/>/igm, "");
}
T.html=function () {
return this.innerhtml?this.innerhtml:null;
}
T.first=function () {
return this.firstchild?this.firstchild.nodename!= "#text" sx.$ (this.firstchild): Null:null;
}
T.last=function () {
return this.lastchild?this.lastchild.nodename!= "#text" sx.$ (this.laschild): Null:null;
}
T.pre=function () {
Return this.previoussibling?sx.$ (this.previoussibling): null;
}
T.next=function () {
Return this.nextsibling?sx.$ (this.nextsibling): null;
}
T.parent=function () {
Return this.parentnode?sx.$ (This.parentnode): null;
}
T.setevent=function (e,f) {
if (t.attachevent) {
T.attachevent ("on" +e,f);
}else{
T.addeventlistener (E,f,false);
}
}
T.removeevent=function (e,f) {
if (t.dettachevent) {
T.dettachevent ("on" +e,f);
}else{
T.removeeventlistener (E,f,false);
}
}
T.setstyle=function (s) {
var s=s.split (",");
for (Var i=0;i<s.length;i++) {
var s1=s[i].split (":");
THIS.STYLE[S1[0]]=S1[1];
}
}
T.getstyle=function (s) {
if (This.currentstyle) {
return This.currentstyle[s];
}else{
Return Document.defaultView.getComputedStyle (this,null). GetPropertyValue (s);
}
}
T.selectpath=function (m) {
var m1=m;
var m=m.split ("/");
var t=[];
var e=this.getelementsbytagname ("*");
for (Var i=0;i<e.length;i++) {
var e1=e[i]
var a= "";
var i1=m.length-1;
while (E1!=this) {
a=e1.tagname+ "/" +A;
E1=e1.parentnode;
alert (a);
}
alert (a);
if (m1.tolowercase () + "/" ==a.tolowercase ()) {
T.push (sx.$ (e[i));
}
}
return t;
}
T.get=function (a) {
Return This.getattribute (a);
}
T.set=function (a,v) {
Return This.setattribute (A,V);
}
T.paste=function (h) {
if (typeof (h) = = "string") {
var d=document.createelement ("span");
D.innerhtml=h;
}else{
var d=document.createelement ("span");
D.appendchild (h);
}
var t1=this.childnodes;
for (Var i=0;i<t1.length;i++) {
Alert (T1[i])
This.removechild (T1[i]);
}
This.appendchild (d);
D.removenode (FALSE);
}
return t;
}
Sx.$$=function () {
var t=[]
for (Var i=0;i<arguments.length;i++) {
T.push (sx.$ (arguments[i))
}
return t;
}

The code above is a core piece of code that I recently wrote across the platform JavaScript framework, I can see that I use the recursive implementation of consonant syntax, in its own method constantly call itself, so that the experimental closure, so that the object continuous operation. By the way, I'm using the method for the T object here, and if it's a property, Then it will be shown in the innerHTML.

Immediately to the exam, not too much time to study and research, although their own professional and computer-related, but still wish they don't hang class it.
The inadequacy of the article, but also hope that you do a lot of corrections.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.