87,993
社区成员
发帖
与我相关
我的任务
分享
function Slider(opt){
this.elem = opt.dom;
console.log(this.elem)
this.sliders = this.elem.getElementsByClassName("banner");
// console.log(5 < this.sliders.length);
// this.slidersLen = this.sliders.length;
init();
function init(){
renderDom();
}
function renderDom(){
//渲染页面
if (opt.direction == "horizontal") {
for (var i = 0; i < this.sliders.length; i++) {
this.sliders[i].style.position = "relative";
this.style.top = 0;
this.style.left = 0;
}
}
}
function bindDom(){
//绑定事件
}
}
window.onload = function (){
var banner = document.getElementById("container");
new Slider({dom:banner,direction:"horizontal"});
}

function Slider(opt) {
this.elem = opt.dom;
this.sliders = this.elem.getElementsByClassName("banner");
this.init();
this.init = function () {
renderDom.call(this);
}
function renderDom() {
if (opt.direction == "horizontal") {
for (var i = 0; i < this.sliders.length; i++) {
this.sliders[i].style.position = "relative";
this.style.top = 0;
this.style.left = 0;
}
}
}
function bindDom() {
//绑定事件
}
}
function Slider(opt){
this.elem = opt.dom;
console.log(this.elem)
this.sliders = this.elem.getElementsByClassName("banner");
// console.log(5 < this.sliders.length);
// this.slidersLen = this.sliders.length;
var _this = this;
init();
function init(){
renderDom();
}
function renderDom(){
//渲染页面
if (opt.direction == "horizontal") {
for (var i = 0; i < _this.sliders.length; i++) {
_this.sliders[i].style.position = "relative";
_this.sliders[i].style.top = 0;
_this.sliders[i].style.left = 0;
}
}
}
function bindDom(){
//绑定事件
}
}
window.onload = function (){
var banner = document.getElementById("container");
new Slider({dom:banner,direction:"horizontal"});
}