我为我的html页面编写了一个javascript,它的工作正常,除了它在每次点击时重新加载。我不知道为什么。我添加了return false
但它仍在重新加载。请告诉我原因。
window.onload = function() {
for (var i = 0; i <= 9; ++i) {
document.getElementById('edit' + i).addEventListener('click', (function(i) {
return function() {
document.getElementById(i + "1").style.display = "none";
document.getElementById(i + "2").style.display = "table-row";
return false;
}
}(i)));
document.getElementById('cancel' + i).addEventListener('click', (function(i) {
return function() {
document.getElementById(i + "2").style.display = "none";
document.getElementById(i + "1").style.display = "table-row";
return false;
}
}(i)));
document.getElementById('link' + i).addEventListener('click', (function(i) {
return function() {
if (document.getElementById("option" + i).style.display == "none") {
document.getElementById("option" + i).style.display = "table-row";
return false;
} else {
document.getElementById("option" + i).style.display = "none";
return false;
}
}
}(i)));
}
return false;
};