-2
我一直致力於使用幻燈片顯示不同元素的JavaScript程序。截至目前,我的程序正確顯示了3張幻燈片,但沒有顯示第四張幻燈片。我仍然難以理解它爲什麼這樣做。在javascript幻燈片中顯示第4張幻燈片
下面是代碼:
$(function() {
var points = 5;
points++;
$("#draggable").draggable();
$("#droppable").droppable({
tolerance: 'pointer',
drop: function(event, ui) {
$(this)
.addClass("second_class")
.find("p")
.html(alert(points--));
}
});
$("#droppable2").droppable({
tolerance: 'pointer',
greedy: false,
drop: function(event, ui) {
$(this)
.find("p")
.html(alert(points++));
},
over: function(event, ui) {
$("#droppable").droppable("disable")
},
over: function(event, ui) {
$("#droppable").droppable("enable")
}
});
});
$(function() {
var points = 5;
points++;
$("#draggable2").draggable();
$("#droppable3").droppable({
tolerance: 'pointer',
drop: function(event, ui) {
$(this)
.addClass("second_class")
.find("p")
.html(alert(points--));
}
});
$("#droppable4").droppable({
tolerance: 'pointer',
greedy: false,
drop: function(event, ui) {
$(this)
.find("p")
.html(alert(points++));
},
over: function(event, ui) {
$("#droppable3").droppable("disable")
},
over: function(event, ui) {
$("#droppable3").droppable("enable")
}
});
});
$(function() {
var points = 5;
points++;
$("#draggable5").draggable();
$("#droppable6").droppable({
tolerance: 'pointer',
drop: function(event, ui) {
$(this)
.addClass("second_class")
.find("p")
.html(alert(points--));
}
});
$("#droppable6").droppable({
tolerance: 'pointer',
greedy: false,
drop: function(event, ui) {
$(this)
.find("p")
.html(alert(points++));
},
over: function(event, ui) {
$("#droppable5").droppable("disable")
},
over: function(event, ui) {
$("#droppable5").droppable("enable")
}
});
});
$("#open_popup").click(function() {
$("#popup").css("display", "block");
});
$("#close_popup").click(function() {
$("#popup").css("display", "none");
});
$("#open_popup2").click(function() {
$("#popup2").css("display", "block");
});
$("#close_popup2").click(function() {
$("#popup2").css("display", "none");
});
$("#open_popup3").click(function() {
$("#popup2").css("display", "block");
});
$("#close_popup3").click(function() {
$("#popup2").css("display", "none");
});
var slideIndex = 0;
showSlides();
function showSlides() {
var i;
var slides = document.getElementsByClassName("mySlides");
var dots = document.getElementsByClassName("dot");
for (i = 0; i < slides.length; i++) {
slides[i].style.display = "none";
}
slideIndex++;
if (slideIndex > slides.length) {
slideIndex = 1
}
for (i = 0; i < dots.length; i++) {
dots[i].className = dots[i].className.replace(" active", "");
}
slides[slideIndex - 1].style.display = "block";
dots[slideIndex - 1].className += " active";
setTimeout(showSlides, 2000); // Change image every 10 seconds
}
var playing = true;
var pauseButton = document.getElementById('pause');
function pauseSlideshow() {
pauseButton.innerHTML = 'Play';
playing = false;
clearInterval(slideIndex);
}
function playSlideshow() {
pauseButton.innerHTML = 'Pause';
playing = true;
setTimeout(showSlides, 3000);
}
請提供您的代碼在您的文章,請參閱[如何提問](http://stackoverflow.com/help/how-to-ask)。 – hungerstar
只包含與特定問題相關的代碼。所有的可拖動和雜項事件處理程序都沒有相關性,應該刪除 – charlietfl
對不起,我打算髮布的是鏈接到js小提琴。 http://jsfiddle.net/reinhardt_scott/rA4CB/187/ –