This time I will share jQuery Plugin and tutorial about Material Design Style Checkboxes In jQuery – matd_checkbox, hope it will help you in programming stack.
The matd_checkbox jQuery plugin lets you create customizable, Material Design style checkboxes with support for indeterminate state.
How to use it:
1. Add jQuery library and the jQuery matd_checkbox plugin’s files to the page.
1 |
< link rel = "stylesheet" href = "matd_checkbox.css" > |
3 |
< script src = "matd_checkbox.min.js" ></ script > |
2. Attach the function matd_checkbox()
to the regular checkbox input and done.
1 |
< input id = "example" type = "checkbox" > |
1 |
$( '#example' ).matd_checkbox(); |
3. Enable the indeterminate state. Default: false.
1 |
$( '#example' ).matd_checkbox({ |
4. Check the checkbox input on init. Default: false.
1 |
$( '#example' ).matd_checkbox({ |
5. Customize the colors of the Material Design checkbox.
1 |
$( '#example' ).matd_checkbox({ |
6. Customize the template of the Material Design checkbox.
1 |
$( '#example' ).matd_checkbox({ |
2 |
templateString: '<span class="matd_cb_container"><span class="flex-base matd_cb_inner" data-checked="${checked}" data-indeterminate="${partial}"><svg class="matd_cb_svg" focusable="false" viewBox="0 0 24 24" aria-hidden="true" role="presentation"><path class="matd_cb_off" style="${style_out_color}" d="M19 5v14H5V5h14m0-2H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2z"></path><path class="matd_cb_on" style="${style_color}" d="M19 3H5c-1.11 0-2 .9-2 2v14c0 1.1.89 2 2 2h14c1.11 0 2-.9 2-2V5c0-1.1-.89-2-2-2zm-9 14l-5-5 1.41-1.41L10 14.17l7.59-7.59L19 8l-9 9z"></path><path class="matd_cb_part" style="${style_color}" d="M19 3H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zm-2 10H7v-2h10v2z"></path></svg><input id="mtdcb_${id}" ${placeholder} class="matd_cb_input" type="checkbox" value="chk_val"></span></span>' , |
7. Check/uncheck the checkbox programmatically.
1 |
$( '#example' ).matd_checkbox( 'go_check' , true ); |
2 |
$( '#example' ).matd_checkbox( 'go_check' , false ); |
This awesome jQuery plugin is developed by CBairdAsh. For more Advanced Usages, please check the demo page or visit the official website.