Off-campus internship front-end work one months, the first time with the object-oriented click to Toggle tab components, click the left and right buttons to switch between the different options
A component based on the JQ
To create a constructor function
function Shownews (selector) {
this.i=0;
this.num=$ (selector). length;
}
Adding a switchover method
Shownews.prototype.show=function (SELECTOR,NEXTBTN,PREVBTN) {
var _this=this;
Next one
$ (NEXTBTN). Click (function () {
_this.i++;
if (_this.i>=_this.num) {
_this.i=0;
}
$ (selector). EQ (_this.i). Show (). siblings (). Hide ();
});
The previous one
$ (PREVBTN). Click (function () {
_this.i--;
if (_this.i==-1) {
_this.i=_this.num-1;
}
$ (selector). EQ (_this.i). Show (). siblings (). Hide ();
})
}
Calling methods
var industrynew=new shownews (selector);
Industrynew.show (SELECTOR,NEXTBTN,PREVBTN);
Object-oriented tab components