/ Published in: HTML
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
<script type="text/javascript" language="javascript"> $( function() { $( '.checkAll' ).live( 'change', function() { $( '.cb-element' ).attr( 'checked', $( this ).is( ':checked' ) ? 'checked' : '' ); $( this ).next().text( $( this ).is( ':checked' ) ? 'Uncheck All' : 'Check All' ); }); $( '.invertSelection' ).live( 'click', function() { $( '.cb-element' ).each( function() { $( this ).attr( 'checked', $( this ).is( ':checked' ) ? '' : 'checked' ); }).trigger( 'change' ); }); $( '.cb-element' ).live( 'change', function() { $( '.cb-element' ).length == $( '.cb-element:checked' ).length ? $( '.checkAll' ).attr( 'checked', 'checked' ).next().text( 'Uncheck All' ) : $( '.checkAll' ).attr( 'checked', '' ).next().text( 'Check All' ); }); }); </script> <div class="controls"> </div> <div class="elements"> </div>