例如有一段代码<script>
function button1(day)
{
document.getElementById("button1").style.display = "none";
document.getElementById("input1").style.display = "none";
document.getElementById("button2").style.display = "block";
document.getElementById("input2").style.display = "block";
}
function button2(day)
{
document.getElementById("button1").style.display = "none";
document.getElementById("input1").style.display = "none";
document.getElementById("button2").style.display = "block";
document.getElementById("input2").style.display = "block";
}
</script>
<form>
<div>
<input type="text" id="input1" />
<input type="button" id="button1" onclick="button1(id);">
</div>
<div>
<input type="text" id="input2" />
<input type="button" id="button2" onclick="button1(id);">
</div>
这是我简写的一段代码 主要意思是 想实现点击 按钮button1的时候 隐藏 button1 显示button2
点击button2 的时候显示button1
但是 如果这个代码在循环里的话 不管点击哪个 效果只显示在第一个上了 . 我想让他点击哪个效果就出现在哪个上面
提交时那个ID 是可以传得 不知道应该怎么用
看我写了这么多字 就帮帮忙吧
function button1(day)
{
document.getElementById("button1").style.display = "none";
document.getElementById("input1").style.display = "none";
document.getElementById("button2").style.display = "block";
document.getElementById("input2").style.display = "block";
}
function button2(day)
{
document.getElementById("button1").style.display = "none";
document.getElementById("input1").style.display = "none";
document.getElementById("button2").style.display = "block";
document.getElementById("input2").style.display = "block";
}
</script>
<form>
<div>
<input type="text" id="input1" />
<input type="button" id="button1" onclick="button1(id);">
</div>
<div>
<input type="text" id="input2" />
<input type="button" id="button2" onclick="button1(id);">
</div>
这是我简写的一段代码 主要意思是 想实现点击 按钮button1的时候 隐藏 button1 显示button2
点击button2 的时候显示button1
但是 如果这个代码在循环里的话 不管点击哪个 效果只显示在第一个上了 . 我想让他点击哪个效果就出现在哪个上面
提交时那个ID 是可以传得 不知道应该怎么用
看我写了这么多字 就帮帮忙吧
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货