Home > Web Front-end > JS Tutorial > 3Z version of image checkbox based on jquery (asp.net jquery)_jquery

3Z version of image checkbox based on jquery (asp.net jquery)_jquery

WBOY
Release: 2016-05-16 18:29:47
Original
1033 people have browsed it

先上效果图:
3Z version of image checkbox based on jquery (asp.net jquery)_jquery

html:

复制代码 代码如下:


01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33


JS:
复制代码 代码如下:

(function($){
$.fn.imagecheckbox = function(options) {
var defaults = {
checked: "images/radio.gif",
unchecked: "no_images/radio.gif",
css: "on",
hide_radios_checkboxes: false
};
var opt = $.extend(defaults, options);
this.each(function(){
var obj = $(this);
var type = obj.attr('type');
var id = obj.attr('id');
if(!opt.hide_radios_checkboxes){
obj.css('display','none');
}
if(obj.attr('checked')){
$("label[for='" id "']").attr('class',opt.css);
}else{
$("label[for='" id "']").attr('class','out');
}
$("label[for='" id "']").click(function(){
$("#" id).trigger("click");
if($(this).attr('class') == opt.css){
$(this).attr('class', 'out');
}else {
$(this).attr('class', opt.css);
}
});
});
}
})(jQuery);

使用方式:(把css一起发出来)
复制代码 代码如下:




Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template