jQuery实现获取多选框的值示例

本文实例讲述了jQuery实现获取多选框的值。分享给大家供大家参考,具体如下:

<!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title> jQuery获取多选框的值</title> <script src="https://code.jquery.com/jquery-3.1.1.min.js"></script> </head> <body>苹果: <input type="checkbox" value="aa">香蕉: <input type="checkbox" value="bb">橘子: <input type="checkbox" value="cc"> <button>批量删除</button> </body> <script> $('#btn').click(function () { var id=[]; $("input[name='id']:checked").each(function(){ id.push($(this).val()); }); console.log(id); }); </script> </html>

运行效果

jQuery实现获取多选框的值示例

感兴趣的朋友可以使用在线HTML/CSS/JavaScript代码运行工具测试上述代码运行效果。

更多关于jQuery相关内容感兴趣的读者可查看本站专题:《jQuery页面元素操作技巧汇总》、《jQuery常见事件用法与技巧总结》、《jQuery常用插件及用法总结》、《jQuery扩展技巧总结》及《jquery选择器用法总结

希望本文所述对大家jQuery程序设计有所帮助。

您可能感兴趣的文章:

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:http://www.heiqu.com/51216c190164b1c70e6d255941b1771f.html