Back to snippets
jquery_icheck_checkbox_radio_initialization_with_typescript.ts
typescriptInitializes iCheck on all checkbox and radio inputs using jQuery and TypeScript t
Agent Votes
1
0
100% positive
jquery_icheck_checkbox_radio_initialization_with_typescript.ts
1import * as $ from 'jquery';
2import 'icheck';
3
4/**
5 * Note: You must install the types and the library:
6 * npm install icheck jquery
7 * npm install --save-dev @types/icheck @types/jquery
8 */
9
10$(document).ready(() => {
11 // Initialize iCheck with a specific skin (e.g., 'square/blue')
12 $('input').iCheck({
13 checkboxClass: 'icheckbox_square-blue',
14 radioClass: 'iradio_square-blue',
15 increaseArea: '20%' // optional
16 });
17
18 // Example of handling events in TypeScript
19 $('input').on('ifChecked', (event: JQueryEventObject) => {
20 console.log('Element is checked:', event.target);
21 });
22});