Can someone tell me why my function doesn't work?
<body onload="changeImage();">
Javascript
var Slider = {
monImage: document.getElementById('imgSlider1'),
imageArray: ['img/slider/1.png', 'img/slider/2.png', 'img/slider/3.png'],
imageIndex: 1,
launch_functions_slider: function () {
this.changeImage();
},
changeImage: function () {
this.monImage.setAttribute('src', this.imageArray[this.imageIndex]);
this.imageIndex++;
if (this.imageIndex > 3) {
this.imageIndex = 0;
}
}
}
script.js
var mainSlider = {
mainSlide: Object.create(Slider),
Slider_run: function () {
this.slide.launch_functions_slider();
}
}
app.js
function appMap() {
var slider_ = Object.create(mainSlider);
slider_.Slider_run();
}
您正在尝试访问对象方法,但未使用该对象,请尝试以下操作, <body onload="Slider.changeImage()">
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.