iCheck
特色:
1、在不同瀏覽器(包括ie6+)和設備上都有相同的表現 — 包括 桌面和移動設備
2、支持觸摸設備 — iOS、Android、BlackBerry、Windows Phone等系統
4、方便定制 — 用HTML 和 CSS 即可為其設置樣式 (多套皮膚)
5、體積小巧 — gzip壓縮后只有1 kb
6、25 種參數 用來定制復選框(checkbox)和單選按鈕(radio button)
7、8 個回調事件 用來監聽輸入框的狀態
8、7個方法 用來通過編程方式控制輸入框的狀態
9、能夠將輸入框的狀態變化同步回原始輸入框中, 支持所有選擇器
使用方法:
$('input').iCheck('check'); //將輸入框的狀態設置為checked
$('input').iCheck('uncheck'); //移除 checked 狀態
$('input').iCheck('toggle'); //toggle checked state
$('input').iCheck('disable'); //將輸入框的狀態設置為 disabled
$('input').iCheck('enable'); //移除 disabled 狀態
$('input').iCheck('update'); //apply input changes, which were done outside the plugin
$('input').iCheck('destroy'); //移除iCheck樣式
調用iCheck時,只需要將修改了默認值的參數列出來即可:
//基礎使用方法 $('input').iCheck({ labelHover : false, cursor : true, checkboxClass : 'icheckbox_square-blue', radioClass : 'iradio_square-blue', increaseArea : '20%' });
下面是參數列表及其默認值:
{ handle: '', checkboxClass: 'icheckbox', radioClass: 'iradio', checkedClass: 'checked', checkedCheckboxClass: '', checkedRadioClass: '', uncheckedClass: '', uncheckedCheckboxClass: '', uncheckedRadioClass: '', disabledClass: 'disabled', disabledCheckboxClass: '', disabledRadioClass: '', enabledClass: '', enabledCheckboxClass: '', enabledRadioClass: '', hoverClass: 'hover', focusClass: 'focus', activeClass: 'active', labelHover: true, labelHoverClass: 'hover', increaseArea: '', cursor: false, inheritClass: false, inheritID: false, insert: '' }
我們可以對上面列出的任何class重置樣式
皮膚
Black — minimal.css //黑色
Red — red.css //紅色
Green — green.css //綠色
Blue — blue.css //藍色
Aero — aero.css //win7中的那種玻璃效果
Grey — grey.css //銀灰色
Orange — orange.css //橙色
Yellow — yellow.css //黃色
Pink — pink.css //粉紅色
Purple — purple.css //紫色
(請自行下載這些皮膚包)
初始化
首先,引入jQuery庫文件
其次,引入jquery.icheck.js插件文件
(如果要引入相關皮膚,則需引入:相關主題顏色.css文件)
回調事件
iCheck支持所有選擇器(selectors),并且只針對復選框checkbox和單選radio按鈕起作用
iCheck提供了大量回調事件,都可以用來監聽change事件
使用on()方法綁定事件:
$('input').on('ifChecked', function(event){ //ifCreated 事件應該在插件初始化之前綁定 alert(event.type + ' callback'); }); bootstrap iCheck中的radio和checkbox的大小可以調整嗎? .icheckbox_square-blue, .iradio_square-blue { display: block; margin: 0; padding: 0; width: 22px; height: 22px; background: url(blue.png) no-repeat; border: none; cursor: pointer; }
如果要調整icheck的radio或checkbox樣式,通過上面的css修改width和height,同時修改blue.png圖片對應的尺寸。
下面看下bootstrap icheck 如何獲取radio的value值
針對下面一組radio,在使用icheck的時候怎么才能獲取到value值 1或 0呢?
以上所述是小編給大家介紹的Bootstrap的iCheck插件checkbox和radio,希望對大家有所幫助,如果大家有任何疑問請給我留言,小編會及時回復大家的。在此也非常感謝大家對綠夏網網站的支持!