我创建了一些 div;它们的 innerHTML 属性会根据显示的当前图像(由 定义imageArray[value]
)进行更改。我遇到的问题是这个函数中的条件不能正常工作。此函数运行每条语句并在最后一个条件括号中的值处停止。这可能是一个逻辑问题或缺少一段代码,但我想听听您对如何解决这个问题的想法。
prevImage()
此功能通过or触发nextImage()
:
function textChange(){
var titleMod = document.getElementById('title');
var dateMod = document.getElementById('date');
var infoMod = document.getElementById('info');
var pagelink = document.getElementById('enter');
if(new_image = imageArray[0]){
titleMod.innerHTML = "This is Image 1";
dateMod.innerHTML = "july 12 12";
infoMod.innerHTML = "<p>paragraph goes in here</p>";
pagelink.onclick = "window.location.href='house.html';"
alert('\o/');
}
if(new_image = imageArray[1]){
titleMod.innerHTML = "This is Image 2";
dateMod.innerHTML = "july 12 19";
infoMod.innerHTML = "<p>paragraph</p>";
pagelink.onclick = "window.location.href='contact.html';"
alert('lolol');
}
if(new_image = imageArray[2]){
titleMod.innerHTML = "This is Image 3";
dateMod.innerHTML = "july 12 19";
infoMod.innerHTML = "<p>paragraph</p>";
pagelink.onclick = "window.location.href='contact.html';"
alert('thisWorks');
}
}