jquery的map方法研究
<p><b>Values: </b></p><form> <input type="text" name="name" value="John"/> <input type="text" name="password" value="password"/> <input type="text" name="url" value="http://ejohn.org/"/></form>
$("p").append( $("input").map(function(){ return $(this).val();}).get().join(", ") ); 其中.get()方法是js中array中的方法[ <p>John, password, http://ejohn.org/</p> ]
$.map( [0,1,2], function(n){ return n + 4;}); [4, 5, 6]
jQuery.map(array,callback),也就是说,map中第一个参数只能是array数组。。。。。。
<script type="text/javascript">$(function(){var arr=new Array();arr[0]="chengxingfang";arr[1]=18;$.map(arr,function(item){alert(item)});</script>