国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > JavaScript > 正文

3Z版基于jquery的圖片復選框(asp.net+jquery)

2019-11-21 00:35:00
字體:
來源:轉載
供稿:網友

先上效果圖:

html:

復制代碼 代碼如下:

<asp:CheckBoxList ID="CheckBoxList1" runat="server" RepeatDirection="Horizontal" RepeatLayout="Flow" Width="280px">
<asp:ListItem>01</asp:ListItem>
<asp:ListItem>02</asp:ListItem>
<asp:ListItem>03</asp:ListItem>
<asp:ListItem>04</asp:ListItem>
<asp:ListItem>05</asp:ListItem>
<asp:ListItem>06</asp:ListItem>
<asp:ListItem>07</asp:ListItem>
<asp:ListItem>08</asp:ListItem>
<asp:ListItem>09</asp:ListItem>
<asp:ListItem>10</asp:ListItem>
<asp:ListItem>11</asp:ListItem>
<asp:ListItem>12</asp:ListItem>
<asp:ListItem>13</asp:ListItem>
<asp:ListItem>14</asp:ListItem>
<asp:ListItem>15</asp:ListItem>
<asp:ListItem>16</asp:ListItem>
<asp:ListItem>17</asp:ListItem>
<asp:ListItem>18</asp:ListItem>
<asp:ListItem>19</asp:ListItem>
<asp:ListItem>20</asp:ListItem>
<asp:ListItem>21</asp:ListItem>
<asp:ListItem>22</asp:ListItem>
<asp:ListItem>23</asp:ListItem>
<asp:ListItem>24</asp:ListItem>
<asp:ListItem>25</asp:ListItem>
<asp:ListItem>26</asp:ListItem>
<asp:ListItem>27</asp:ListItem>
<asp:ListItem>28</asp:ListItem>
<asp:ListItem>29</asp:ListItem>
<asp:ListItem>30</asp:ListItem>
<asp:ListItem>31</asp:ListItem>
<asp:ListItem>32</asp:ListItem>
<asp:ListItem>33</asp:ListItem>
</asp:CheckBoxList>

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一起發出來)
復制代碼 代碼如下:

<script type="text/javascript" src="/scripts/imagetick.js"></script>
<script type="text/javascript">
$(function(){
$("input[type='checkbox']").imagecheckbox({ // the selector can be a class as well
checked: "/images/red.gif",
onchecked: "/images/no_check.gif",
css: "on"
});
});
</script>
<style type="text/css">
input{}
label{display:inline-block;width:25px;height:22px;padding-top:3px;text-align:center;font:800 12px/150% arial;position:relative;left;-210px;}
.on{background:url(/images/red.gif) no-repeat;}
.out{background:url(/images/no_check.gif) no-repeat;}
</style>

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 茶陵县| 沙雅县| 全南县| 武强县| 轮台县| 海淀区| 泉州市| 嘉荫县| 梧州市| 丰顺县| 泸水县| 菏泽市| 双流县| 广宁县| 承德县| 利川市| 临武县| 子洲县| 泰和县| 睢宁县| 波密县| 利川市| 兴和县| 呼玛县| 清河县| 紫云| 孙吴县| 毕节市| 莆田市| 田东县| 安泽县| 德保县| 米林县| 德令哈市| 泰和县| 荥阳市| 齐齐哈尔市| 邳州市| 绥棱县| 青龙| 兴和县|