论坛首页 Web前端技术论坛

jQuery全选

浏览 4672 次
锁定老帖子 主题:jQuery全选
精华帖 (0) :: 良好帖 (0) :: 新手帖 (0) :: 隐藏帖 (19)
作者 正文
   发表时间:2008-01-16  
  1. <script type="text/javascript">
  2. $(function() {
  3. $("#selectall").click(function() {
  4. $("input[@name='shareuser[]']").each(function() {
  5. $(this).attr("checked", true);
  6. });
  7. });
  8. $("#deselectall").click(function() {
  9. $("input[@name='shareuser[]']").each(function() {
  10. $(this).attr("checked", false);
  11. });
  12. });
  13. });
  14. </script>
  15. <input type='checkbox' id='in-shareuser-10' name='shareuser[]' value='10' />UserA
  16. <input type='checkbox' id='in-shareuser-11' name='shareuser[]' value='11' />UserB
  17. <input type='checkbox' id='in-shareuser-12' name='shareuser[]' value='12' />UserC
  18. <input type="button" id="selectall" name="selectall" value="全选" />
  19. <input type="button" id="deselectall" name="deselectall" value="取消全选" />
论坛首页 Web前端技术版

跳转论坛:
Global site tag (gtag.js) - Google Analytics