jquery map method usage example_jquery
jquery
map
jQuery.map( array, callback(elementOfArray, indexInArray) )
Returns: Array
I feel that jquery’s map method is very easy to use, so I would like to share it with you.
Method function: Replace an array or a single object with new content.
Application example: Get a set of checkbox values, separated by English commas, and spliced together.
Copy code The code is as follows:
< head>
< script>
$(function(){
$("input").click(function(){
var str = $(":checked").map(function(){
return this.value;
}).get().join(",")
$("span").html(str);
})
})
< ;/script>
a
b
c
Result display: