Javascript图像滑块-需要添加按钮

Javascript图像滑块-需要添加按钮,javascript,html,css,web,Javascript,Html,Css,Web,请看下面我的代码。这段代码运行良好,但我想添加暂停/恢复、前进和后退按钮。因此,如果有人单击“暂停”,它将停止自动旋转。我不能使用Jquery。我处理过这段代码,但我无法向这段代码中添加按钮 (函数(){ 功能幻灯片(元素){ this.el=document.querySelector(元素); this.init(); } Slideshow.prototype={ init:function(){ this.wrapper=this.el.querySelector(“.slider w

请看下面我的代码。这段代码运行良好,但我想添加暂停/恢复、前进和后退按钮。因此,如果有人单击“暂停”,它将停止自动旋转。我不能使用Jquery。我处理过这段代码,但我无法向这段代码中添加按钮

(函数(){
功能幻灯片(元素){
this.el=document.querySelector(元素);
this.init();
}
Slideshow.prototype={
init:function(){
this.wrapper=this.el.querySelector(“.slider wrapper”);
this.slides=this.el.queryselectoral(“.slide”);
this.previous=this.el.querySelector(“.slider-previous”);
this.next=this.el.querySelector(“.slider next”);
该指数=0;
this.total=this.slides.length;
this.timer=null;
这个动作();
这是stopStart();
},
_slideTo:功能(幻灯片){
var currentSlide=this.slides[slide];
currentSlide.style.opacity=1;
对于(var i=0;i
html,正文{
保证金:0;
填充:0;
}
.滑块{
宽度:1024px;
利润率:2米自动;
}
.滑块包装器{
宽度:100%;
高度:400px;
位置:相对位置;
}
.幻灯片{
浮动:左;
位置:绝对位置;
宽度:100%;
身高:100%;
不透明度:0;
过渡:线性;
}
.slider wrapper>.slide:第一个子项{
不透明度:1;
}

这可以通过这种方式完成

(函数(){
功能幻灯片(元素){
this.el=document.querySelector(元素);
this.init();
}
Slideshow.prototype={
init:function(){
this.wrapper=this.el.querySelector(“.slider wrapper”);
this.slides=this.el.queryselectoral(“.slide”);
该指数=0;
this.total=this.slides.length;
this.timer=null;
this.nextButton=document.querySelector('next');
this.previousButton=document.querySelector(“#previous”);
this.toggleButton=document.querySelector(“#toggle”);
这个动作();
这是stopStart();
这个.toggleButton.addEventListener('click',函数(e){
e、 预防默认值();
这个。停止();
}.约束(这个);
this.nextButton.addEventListener('click',函数(e){
e、 预防默认值();
这个。下一个();
}.约束(这个);
此.previousButton.addEventListener('click',函数(e){
e、 预防默认值();
这是先前的();
}.绑定(本)
},
_slideTo:功能(幻灯片){
var currentSlide=this.slides[slide];
currentSlide.style.opacity=1;
对于(var i=0;i

暂停
下一个
以前的