<!DOCTYPE html><html><head>
<style>p { color:red; }</style>
<script type="text/javascript" src="/jquery/jquery.js"></script></head><body>
<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://w3school.com.cn/"/>
</form><script>
$("p").append( $("input").map(function(){ return $(this).val();
}).get().join(", ") );</script></body></html>在W3C上面看到的一個例子,對于里面的<script>不太理解。我想問一下,為什么要在js代碼里加一個get()方法呢?我看了下jquery的官方文檔,get()方法的參數不是需要一個index嗎,比如get(0),get(1)之類的。我知道這段js代碼一直到get()之前,目的就是把所有input的value包裝成一個數組返回,然后join(',')連接成一個字符串,就是不理解這個為什么要加一個不帶參的get()求各位高人解答,謝謝啦(∩_∩)
jquery中get()方法的問題
夢里花落0921
2018-08-09 10:10:00