zoukankan      html  css  js  c++  java
  • jquery全选反选

    View Code
    <head>
    <title></title>

    <script src="js/jquery-1.4.2.js" type="text/javascript"></script>

    <script type="text/javascript">
    $(
    function() {
    $(
    "#selall").click(function() { //取得id为aaa的标签下面的类型为chexkbox的控件。 $("#aaa :checkbox").attr("checked", true);// 将其checked属性实质为true
    });
    });
    $(
    function() {
    $(
    "#noselall").click(function() { //取得id为aaa的标签下面的类型为chexkbox的控件。
    $("#aaa :checkbox").attr("checked", false); // 将其checked属性实质为false
    });
    });
    $(
    function() {
    $(
    "#reverse").click(function() { //取得id为reserse的控件
    $("#aaa :checkbox").each(function() { //遍历其类型为checkbox的空间
    $(this).attr("checked",!$(this).attr("checked"))//将选择的取消,取消的选择
    });
    });
    });
    </script>

    </head>
    <body>
    <div id="aaa">
    <input type="checkbox"/>歌曲一<br />
    <input type="checkbox"/>歌曲二<br />
    <input type="checkbox"/>歌曲三<br />
    <input type="checkbox"/>歌曲四<br />
    </div>
    <input id="selall" type="button" value="全选"/>
    <input id="noselall" type="button" value="全部选"/>
    <input id="reverse" type="button" value="反选"/>
    </body>
  • 相关阅读:
    164.Maximum Gap
    163.Missing Ranges
    162.Find Peak Element
    161.One Edit Distance
    160.Intersection of Two Linked Lists
    7.5爬取猫眼Top100电影名单
    7.5文件操作
    7.4文件操作(1)
    7.4一个失败的网易云爬虫,
    7.3数据结构(1)
  • 原文地址:https://www.cnblogs.com/happygx/p/1982054.html
Copyright © 2011-2022 走看看