求教js大神,怎么让两个input的按钮,当点击第一个的时候,第二个input的按钮再出现。
<body>
<input id="input1" value="" placeholder="input1"> <br />
<input id="input2" value="" placeholder="input2" style="display:none"> <br />
<input id="input3" value="" placeholder="input3" style="display:none">
<script>
$('#input1').click(function(){
$('#input2').show();
});
$('#input2').click(function(){
$('#input3').show();
});
</script>
</body>
是不是要这样的效果,自己引一下jquery.js
给按钮加上点击事件,
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<script>
function btn_block(btn_id){
document.getElementById(btn_id).style.display="block";
}
</script>
</head>
<body>
<form>
<input type="button" id="btn1" value="按钮1" onclick="btn_block('btn2');" />
<input type="button" id="btn2" value="按钮2" onclick="btn_block('btn3');" style="display:none;" />
<input type="button" id="btn3" value="按钮3" style="display:none;" />
</form>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<style type="text/css">
div>input+input{
display: none;
margin-top: 20px;
}
</style>
</head>
<body>
<div>
<input type="button" class="btn" value="按钮1" />
<input type="button" class="btn" value="按钮2" />
<input type="button" class="btn" value="按钮3" />
</div>
</body>
<script type="text/javascript">
var child = document.getElementsByClassName("btn");
child[0].onclick = function () {
child[1].style.display='block';
};
child[1].onclick = function () {
child[2].style.display='block';
}
</script>
</html>