欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

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

 更新時(shí)間:2018年05月24日 09:17:32   作者:lianzhang861  
這篇文章主要介紹了jquery.onoff實(shí)現(xiàn)簡(jiǎn)單的開(kāi)關(guān)按鈕功能,非常不錯(cuò),具有一定的參考借鑒價(jià)值,需要的朋友可以參考下

插件下載地址:

http://xiazai.jb51.net/201803/yuanma/jquery.onoff(jb51.net).rar

一個(gè)按鈕小插件,首先引入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只需要寫(xiě)一個(gè)input

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

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

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

你會(huì)發(fā)現(xiàn)一個(gè)普通的checkbox變成了開(kāi)關(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)擊開(kāi)關(guān)顯示模態(tài)框

jq控制開(kāi)關(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)簡(jiǎn)單的開(kāi)關(guān)按鈕功能,希望對(duì)大家有所幫助,如果大家有任何疑問(wèn)請(qǐng)給我留言,小編會(huì)及時(shí)回復(fù)大家的。在此也非常感謝大家對(duì)腳本之家網(wǎng)站的支持!

相關(guān)文章

最新評(píng)論