ImageSlider
This commit is contained in:
16
MiniProjects/ImageSlider/script.js
Normal file
16
MiniProjects/ImageSlider/script.js
Normal file
@ -0,0 +1,16 @@
|
||||
const files = [];
|
||||
let current = 0;
|
||||
for (let i = 1; i <= 30; i++) {
|
||||
files.push(`(${i}).jpg`);
|
||||
}
|
||||
|
||||
function changeSlide(val){
|
||||
current += val;
|
||||
if (current > files.length - 1) {
|
||||
current = 0;
|
||||
}
|
||||
if (current < 0) {
|
||||
current = files.length - 1;
|
||||
}
|
||||
document.getElementById("slided").src = `./IMG/${files[current]}`;
|
||||
}
|
Reference in New Issue
Block a user