Discuss / JavaScript / 作业

作业

Topic source

Niko

#1 Created at ... [Delete] [Delete and Lock User]

selectAllLabel.click(function(){//当用户勾上“全选”时,自动选中所有语言,并把“全选”变成“全不选”;

    langs.prop('checked',true);

    selectAllLabel.hide();

    deselectAllLabel.show();

});

deselectAllLabel.click(function(){//当用户去掉“全不选”时,自动不选中所有语言;

    langs.prop('checked',false);

    deselectAllLabel.hide();

    selectAllLabel.show();

});

invertSelect.click(function(){//当用户点击“反选”时,自动把所有语言状态反转(选中的变为未选,未选的变为选中);

    langs.map(function(){

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

    });

});

langs.map(function(){

   $(this).change(function(){//当用户把所有语言都手动勾上时,“全选”被自动勾上,并变为“全不选”;

        if($('[name=lang]:checked').length==5){

            selectAll.prop('checked',true);

            selectAllLabel.hide();

            deselectAllLabel.show();

        }else{//当用户手动去掉选中至少一种语言时,“全不选”自动被去掉选中,并变为“全选”。

            selectAll.prop('checked',false);

            selectAllLabel.show();

            deselectAllLabel.hide();

        }

    });

});


  • 1

Reply