<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>菜鸟教程(runoob.com)</title> <script src="http://cdn.static.runoob.com/libs/jquery/1.10.2/jquery.min.js"> </script> </head> <body> <input type="button" id="btn5" value="获得选中的所有值"/> <input type="checkbox" name="checkbox" value="checkbox1" checked> checkbox1 <input type="checkbox" name="checkbox" value="checkbox2"> checkbox2 <input type="checkbox" name="checkbox" value="checkbox3"> checkbox3 <input type="checkbox" name="checkbox" value="checkbox4"> checkbox4 <input type="checkbox" name="checkbox" value="checkbox5"> checkbox5 <input type="checkbox" name="checkbox" value="checkbox6"> checkbox6 <script> $("#btn5").click(function(){//输出选中的值 var str=""; $("[name='checkbox']:checked").each(function(){ str+=$(this).val()+"/r/n"; }) alert(str); }) </script> </body>