+ -
当前位置:首页 → 问答吧 → 大家帮看看,为什么这个jQuery全选,反选,取消用jquery1.2就可以,用1.3就不起作用!

大家帮看看,为什么这个jQuery全选,反选,取消用jquery1.2就可以,用1.3就不起作用!

时间:2009-05-31

来源:互联网

大家帮看看,为什么这个jQuery全选,反选,取消用jquery1.2就可以,用1.3就不起作用!
http://wlog.com.cn/check/d1.html  (1.2)
http://wlog.com.cn/check/d2.html  (1.3)

谢谢!

复制代码
  1. <html>
  2. <head>
  3. <script src="http://jqueryjs.googlecode.com/files/jquery-1.3.2.min.js"></script>
  4. <script type="text/javascript">
  5. $(function() {
  6. //全选
  7. $("#selectall").click(function() {
  8. $("input[@name='shareuser']").each(function() {
  9. $(this).attr("checked", true);
  10. });
  11. });
  12. //反选
  13. $("#fanall").click(function() {
  14. $("input[@name='shareuser']").each(function() {
  15. if($(this).attr("checked"))
  16. {
  17. $(this).attr("checked", false);
  18. }
  19. else
  20. {
  21. $(this).attr("checked", true);
  22. }
  23. });
  24. });
  25. //取消全部
  26. $("#deselectall").click(function() {
  27. $("input[@name='shareuser']").each(function() {
  28. $(this).attr("checked", false);
  29. });
  30. });
  31. //alert
  32. $("#alertall").click(function() {
  33. $("input[@name='shareuser']").each(function() {
  34. if($(this).attr("checked"))
  35. {
  36. alert($(this).val());
  37. }
  38. });
  39. });
  40. });
  41. </script>
  42. <input type='checkbox' id='in-shareuser-10' name='shareuser' value='10' />10
  43. <input type='checkbox' id='in-shareuser-11' name='shareuser' value='11' />11
  44. <input type='checkbox' id='in-shareuser-12' name='shareuser' value='12' />12
  45. <input type="button" id="selectall" name="selectall" value="全选" />
  46. <input type="button" id="fanall" name="fanall" value="反选" />
  47. <input type="button" id="deselectall" name="deselectall" value="取消" />
  48. <input type="button" id="alertall" name="alertall" value="输出" />
[ 此帖被lfxc在2009-05-31 12:19重新编辑 ]

作者: lfxc   发布时间: 2009-05-31

input[@name='shareuser']

1.3改了,去掉@就行了

作者: keakon   发布时间: 2009-05-31

万分感谢!!!!

作者: lfxc   发布时间: 2009-05-31

相关阅读 更多