map
英[m?p] 美[m?p]
n. ??, ?? ??; ? ??> ??, ??; . ?? ???(?? ?), ?? ??;
jquery ?() ??? ???
??: map()? ??? ?? ? ??? ?? ???? ???? ???? ?? ?? ???? ? jQuery ??? ?????.
??: ??.map(callback(index,domElement))
????:
Parameters | Description |
callback(index,domElement) | ??? ? ??? ?? ??? ??? ?? ???? ?? ?????. |
??: ?? ?? jQuery? ???? ????? get()? ???? ??? ??? ???? ?? ??? ?????.
jquery ?() ??? ?
<!DOCTYPE html> <html> <head> <style>p { color:red; }</style> <script type="text/javascript" src="http://apps.bdimg.com/libs/jquery/2.1.1/jquery.min.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://php.cn/"/> </form> <script> $("p").append( $("input").map(function(){ return $(this).val(); }).get().join(", ") ); </script> </body> </html>
??? ????? ??? "???? ??" ??? ?????