日期:2014-05-16 浏览次数:20426 次
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8"/>
<style type="text/css">
</style>
</head>
<body>
<div>
需要的层级:<input type="text" id="num" />
<input type="button" id="ok" value="确定" />
</div>
<div id="can" style="border:1px solid #CCC; display:none; width:300px;"></div>
<input type="button" id="submit" value="submit" />
<div id="show"></div>
</body>
</html>
<script type="text/javascript" src="../jquery-1.8.0.js"></script>
<script type="text/javascript">
$(function(){
$("#ok").bind("click", function(){
var num = parseInt($("#num").val());
var html = '';
for(var i=0; i<num; i++){
html += '<input type="text" /><br/>';
}
$("#can").html(html).css('display', 'block');
})
$("#submit").bind("click", function(){
var input = $("#can input:text");
var html = '';
for(var i=0, t=input.length; i<t; i++){
html += input[i].value+'; ';
}
$("#show").html(html);
})
})
</script>