form表单内部div块隐藏显示问题? 想实现点击修改后出现单选框选择性别
<!DOCTYPEhtml><htmllang="en"><head><metacharset="UTF-8"><title>setting</title><script...
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>setting</title>
<script type="javascript">
function change1()
{
document.getElementById("sex0").style.display = "none";
document.getElementById("sex1").style.display = "block";
}
</script>
</head>
<body>
<div >
<form action="" method="post">
<div>
<span>性别</span>
<div class="name_control" id="sex0" style="display: block">
<span class="js-before">男</span>
<button style="border:none; background:white;" onclick="change1()"><span >修改</span></button>
</div>
<div class="" style="display: none" id="sex1">
<label class=""><input type="radio" name="gender" value="1"> 男</label>
<label class=""><input type="radio" name="gender" value="0"> 女</label>
</div>
</div>
</form>
</div>
</body>
</html> 展开
<html lang="en">
<head>
<meta charset="UTF-8">
<title>setting</title>
<script type="javascript">
function change1()
{
document.getElementById("sex0").style.display = "none";
document.getElementById("sex1").style.display = "block";
}
</script>
</head>
<body>
<div >
<form action="" method="post">
<div>
<span>性别</span>
<div class="name_control" id="sex0" style="display: block">
<span class="js-before">男</span>
<button style="border:none; background:white;" onclick="change1()"><span >修改</span></button>
</div>
<div class="" style="display: none" id="sex1">
<label class=""><input type="radio" name="gender" value="1"> 男</label>
<label class=""><input type="radio" name="gender" value="0"> 女</label>
</div>
</div>
</form>
</div>
</body>
</html> 展开
1个回答
展开全部
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<script type="text/javascript">
function change1()
{
document.getElementById("sex0").style.display = "none";
document.getElementById("sex1").style.display = "block";
}
</script>
</head>
<body>
<div >
<form action="" method="post">
<div>
<span>性别</span>
<div class="name_control" id="sex0" style="display: block">
<span class="js-before">男</span>
<input type="button" style="border:none; background:white;" onclick="change1()" value="修改" />
</div>
<div class="" style="display: none" id="sex1">
<label class=""><input type="radio" name="gender" value="1"> 男</label>
<label class=""><input type="radio" name="gender" value="0"> 女</label>
</div>
</div>
</form>
</div>
</body>
</html>
<button>在ie下只是按钮,但在其他浏览器上是submit,submit类的按钮按下后,会进行提交,并刷新页面,所以按钮按下后页面改变一瞬间又重置了。
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询