JS的选择操作

<script>

全选  true

$("#selectAll").click(function(){

    $(".item").prop("checked",true);

});

全不选  flase

$("#selectNone").click(function(){

    $(".item").prop("checked",false);

});

这个是得到当前的所有选项  遍历得到每一项this

$(this).prop("checked")得到当前的值 取反再赋值  

 

$("#reverse").click(function(){

    let items =$(".item");

    items.each(function(){

        $(this).prop("checked",!$(this).prop("checked"));

    })

});

</script>

posted @ 2020-09-21 16:27  尘缘01  阅读(125)  评论(0编辑  收藏  举报