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

首頁 > 編程 > JavaScript > 正文

jquery.onoff實(shí)現(xiàn)簡單的開關(guān)按鈕功能(推薦)

2019-11-19 13:47:15
字體:
供稿:網(wǎng)友

插件下載地址:

http://xiazai.VeVB.COm/201803/yuanma/jquery.onoff(VeVB.COm).rar

一個按鈕小插件,首先引入css和js

<script type="text/javascript" src="../js/jquery-1.11.3.js" ></script>   <link rel="stylesheet" href="../js/dist/jquery.onoff.css" rel="external nofollow" />   <script type="text/javascript" src="../js/dist/jquery.onoff.js" ></script> 

html只需要寫一個input

<input type="checkbox" checked onclick="showmodel(this)"/> 

然后js中只需要加一個.onoff()

$('input[type=checkbox]').onoff(); 

你會發(fā)現(xiàn)一個普通的checkbox變成了開關(guān)按鈕

關(guān)于顏色和樣式,自己去css中找到相應(yīng)的位置修改即可

onoffswitch-inner:before {  content: "OFF";  padding-left: 3px;  color: #FFFFFF;  background-color: #A14776; } onoffswitch-inner:after {  content: "ON";  padding-right: 5px;  color: #999999;  background-color: #EEEEEE;  text-align: right; } 

關(guān)于事件

我點(diǎn)擊開關(guān)顯示模態(tài)框

jq控制開關(guān)只需要這樣就行

$(ele).prop("checked",true) //或false 
function showmodel(ele){   if(!$(ele).is(':checked')){     var htmls=$(ele).parent().siblings('span').html();     $('.mask').show();     $('#reportName').html(htmls);     $('#yzmBox').html(mathRand());   }   $(".cancel").unbind().click(function(){     $(ele).prop("checked",true)     $('.mask').hide();   })   $(".sure").unbind().click(function(){     if($(".telBox input").val()==$('#yzmBox').html()){       /*$.ajax({         url: ipAddress + "/MMSDailyBackstage/task2/getTaskTypes",         data:{"areaCode":"01","roleCode":"dhxt","appCode":"day_report","imei":"111111111111111"},         type : "POST",         dataType: "json",         cache: false,         async: false,         success:function(json){           var data=json.data;           var html="";           if(json.success){             for(var i in data){               var taskTypeSubs=data[i].taskTypeSubs;                 html+='<div class="col">'+                   '<p onclick="sliderDiv(this)"><span class="arrow down_a"></span><span>'+data[i].taskType.taskTypeName+'</span></p>'+                   '<ul class="lidetail">'                 for(var j in taskTypeSubs){                   html+='<li>'+                       '<img src="../img/aduiticon.png">'+                       '<span>'+taskTypeSubs[j].subTaskName+'</span>'+                       '<input type="checkbox" checked/ onclick="showmodel(this)">'+                     '</li>'                 }                 html+='</ul></div>'             }             $('#auditBox').append(html);             $('input[type=checkbox]').onoff();           }                    }       });*/     }        }) } 

總結(jié)

以上所述是小編給大家介紹的jquery.onoff實(shí)現(xiàn)簡單的開關(guān)按鈕功能,希望對大家有所幫助,如果大家有任何疑問請給我留言,小編會及時回復(fù)大家的。在此也非常感謝大家對武林網(wǎng)網(wǎng)站的支持!

發(fā)表評論 共有條評論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 普陀区| 大足县| 广平县| 固始县| 遵义市| 台州市| 潞西市| 大兴区| 雅江县| 阿荣旗| 龙门县| 西安市| 水富县| 湾仔区| 青海省| 启东市| 页游| 辛集市| 大连市| 丹棱县| 灵武市| 郑州市| 瓦房店市| 库车县| 姜堰市| 中江县| 连南| 齐河县| 兰州市| 岫岩| 黄冈市| 始兴县| 浦县| 噶尔县| 涪陵区| 安达市| 鱼台县| 广南县| 潼南县| 桃江县| 长寿区|