使用jQuery練習全選-取消-反選-顯示選擇內容等功能代碼,jquery全選

來源:互聯網
上載者:User

使用jQuery練習全選-取消-反選-顯示選擇內容等功能代碼,jquery全選

<span style="font-size:24px;color:#ff0000;">部長練習全選-取消-反選-顯示選擇內容等功能代碼:</span>


<!doctype html><html><head><meta charset="gb2312"><title>部長練習全選-取消-反選-顯示選擇內容等功能</title><script src="js/jquery-1.11.1.min.js"></script><script>$(document).ready(function(e) {    //實現全選功能    $(':input[value=全選]').click(function(){        //alert($(this).val());            $('form :checkbox').prop("checked", true);    });    //實現取消功能    $(':input[value=取消]').click(function(){        //$(':checkbox').removeAttr('checked');        //$(':checkbox').attr('checked',false);        $('form :checkbox').prop("checked",false);    });    //實現反選功能    $(':input[value=反選]').click(function(){        $('form :checkbox').each(function(index, element) {            $(this).prop('checked',!$(this).prop('checked'));        });;    });    //實現第二個全選的功能    $('#myall').change(function(){        //alert($(this).prop('checked'));        if($(this).prop('checked')){            $('form :checkbox').prop("checked", true);            $(this).next('span').html('取消');        }else{            $('form :checkbox').prop("checked",false);            $(this).next('span').html('全選');        }    });    //實現顯示選擇的功能    $(':input[value=顯示選擇]').click(function(){        var t = '';        $('form :checked').each(function(index, element) {            t+=$(this).val();        });        alert(t);    });});</script></head><body><form><label><input  type="checkbox" name="love[]" value="音樂">音樂</label><label><input type="checkbox" name="love[]" value="運動">運動</label><label><input type="checkbox" name="love[]" value="看書">看書</label><label><input type="checkbox" name="love[]" value="玩遊戲">玩遊戲</label><label><input type="checkbox" name="love[]" value="看電視">看電視</label><label><input type="checkbox" name="love[]" value="遊戲">遊戲</label><label><input type="checkbox" name="love[]" value="上網">上網</label></form><hr><input type="button" value="全選"> <input type="button" value="反選"> <input type="button" value="取消"> <input type="button" value="顯示選擇"><hr><label><input type="checkbox" id="myall"><span>全選</span></label></body></html>






jquery全選刪除

這裡給你個全選或全不選的方法,刪除的方法就是把table裡面的對應的tr刪除掉,並更新資料庫,$(function () {
$(".ck").click(function () {
if ($(".ck").attr("checked") == "checked") {
$("input:[type='checkbox']").attr("checked", "checked");
}
else {
$("input:[type='checkbox']").removeAttr("checked");
}
});
});
 
jquery 篩選器的使用,做全選,反選,大量刪除用的

$.each($(".mp"),function(){
alert( $(this).val() );
});
 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.