日期:2014-05-16 浏览次数:20420 次
<script type="text/javascript" src="jq.js"></script>
<form action="">
<li><input type="text" class="name" value="11"> <input type="text" class="pas" value="12"></li><br/>
<li><input type="text" class="name" value="21"> <input type="text" class="pas" value="22"></li><br/>
<input type="submit" class="submit">
</form>
<script>
$(function(){
var ar = new Array();
var $li = $("form li");
var li = $li.length;
var lichlen = $li.children('input').length;
for(var i = 0;i < li; i++){
ar[i]=new Array();
for(var j = 0; j< lichlen;j++){
var vale=$li.eq(i).children('input:eq('+j+')').val();
ar[i][j]=vale;
}
}
alert(ar);
})
</script>
<script type="text/javascript" src="scripts/jquery-1.8.3.min.js"></script>
<form action="">
<li><input type="text" class="name" value="11"> <input type="text" class="pas" value="12"></li><br/>
<li><input type="text" class="name" value="21"> <input type="text" class="pas" value="22"></li><br/>
<input type="submit" class="submit">
</form>
<script>
$(function(){
var ar = [];
$("form li").each(function() {
var t = [];
$(this).find(':text').each(function() {
t.push($(this).val());
});
ar.push(t);
});
alert(ar[0]);
alert(ar[1]);
})
</script>
$(function(){
var arr = [];
$("form>li").each(function(k,v){
$(v).find('input').each(function(kk,vv){
var a = arr[kk] = arr[kk]
------解决方案--------------------
[];
var val = $(vv).val();
a.push(val);
})
});
var $b = arr;
})