类似于百度首页点击换一换可以反复切换内容
以下是我的js代码
var moren = ["你好2013","你好2014"];
var mm = document.getElementById("neirong");
var nn = mm.children;
var y = 0;
var temp = 0;
for(var i = 0;i < nn.length;i++)
{
nn[i].innerHTML = moren[y];
y = y + 1;
}
function huanyihuan(){
temp = temp + 1 ;
console.log(temp);
if(temp % 2 ==1 )
{
console.log("偶数");
var moren2 = ["你好2015","你好2017"];
var mm = document.getElementById("neirong");
var nn = mm.children;
var y = 0;
for(var i = 0 ; i < nn.length;i++)
{
nn[i].innerHTML = moren2[y];
y = y + 1;
}
}
else
{
console.log("奇数");
var moren1 = ["你好2016","你好2018"];
var mm = document.getElementById("neirong");
var nn = mm.children;
var y = 0;
for(var i = 0 ; i < nn.length;i++)
{
nn[i].innerHTML = moren1[y];
y = y + 1;
}
}
}
希望将完整的html代码帮忙补一下