<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<style>
</style>
</head>
<body>
<div id="list">
<ul>
<li>
<input type="text" value="">
<ul class="divul">
<li> <input type="text" value=""></li>
<li> <input type="text" value=""></li>
<li> <input type="text" value=""></li>
<li> <input type="text" value=""></li>
</ul>
</li>
<li>
<input type="text" value="">
<ul class="divul">
<li> <input type="text" value=""></li>
<li> <input type="text" value=""></li>
<li> <input type="text" value=""></li>
<li> <input type="text" value=""></li>
</ul>
</li>
<li>
<input type="text" value="">
<ul class="divul">
<li> <input type="text" value=""></li>
<li> <input type="text" value=""></li>
<li> <input type="text" value=""></li>
<li> <input type="text" value=""></li>
</ul>
</li>
</ul>
</div>
<div οnclick="saveAll()">sssssssssssssssss</div>
<script type="text/javascript" src="http://code.jquery.com/jquery-latest.js"></script>
<script type="text/javascript">
function saveAll() {
var array=[];
//获取兄弟地值。
var divul = $(".divul");
var a={};
divul.each(function(){
var question=$(this).parent().find("input").val();
alert("question::"+question)
a.question=question;
var answers = $(this).children();
answers.each(function(index){
var text = $(this).find("input").val();
alert("text:::"+text)
var answer={};
answer.index=index;
answer.text=text;
a.answer = answer;
});
array.push(a);
});
alert("length:"+array.length)
}
</script>
</body>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<style>
</style>
</head>
<body>
<div id="list">
<ul>
<li>
<input type="text" value="">
<ul class="divul">
<li> <input type="text" value=""></li>
<li> <input type="text" value=""></li>
<li> <input type="text" value=""></li>
<li> <input type="text" value=""></li>
</ul>
</li>
<li>
<input type="text" value="">
<ul class="divul">
<li> <input type="text" value=""></li>
<li> <input type="text" value=""></li>
<li> <input type="text" value=""></li>
<li> <input type="text" value=""></li>
</ul>
</li>
<li>
<input type="text" value="">
<ul class="divul">
<li> <input type="text" value=""></li>
<li> <input type="text" value=""></li>
<li> <input type="text" value=""></li>
<li> <input type="text" value=""></li>
</ul>
</li>
</ul>
</div>
<div οnclick="saveAll()">sssssssssssssssss</div>
<script type="text/javascript" src="http://code.jquery.com/jquery-latest.js"></script>
<script type="text/javascript">
function saveAll() {
var array=[];
//获取兄弟地值。
var divul = $(".divul");
var a={};
divul.each(function(){
var question=$(this).parent().find("input").val();
alert("question::"+question)
a.question=question;
var answers = $(this).children();
answers.each(function(index){
var text = $(this).find("input").val();
alert("text:::"+text)
var answer={};
answer.index=index;
answer.text=text;
a.answer = answer;
});
array.push(a);
});
alert("length:"+array.length)
}
</script>
</body>
</html>