Jquery中的prop,方法 全选或全不选

 注意: prop()在高版本才会有效, 低版本用attr();

 $(function(){
        // 元素checkbox
        var aChecked = $('.checkGoods');
        // 全选
        var oAllSelected = $('#checkAll');

        oAllSelected.click(function() {
            var $this = $(this);

            if( $this.prop('checked') ) {
                aChecked.each(function() {
                    $(this).prop('checked', true);
                });
            } else {
                aChecked.each(function() {
                    $(this).prop('checked', false);
                });
            }
        });

    })

        aChecked.each(function() {
                $(this).prop('checked', !$(this).prop('checked'));
       });