1.先引入switchery.css 和 switchery.js

2.绘制 checkbox按钮 : a.静态页面写法  未选中时 <input type="checkbox" class="js-switch_3"  /> switchery按钮使用       选中时  <input type="checkbox" class="js-switch_4" checked /> switchery按钮使用

 

                                     b.C# 写法 (1) @Html.CheckBoxFor(m => m.Active, new { @Class = "js-switch", @checked = Model.Active }) <span> Activate</span>

                                                      (2) @Html.CheckBox("edit_forMave_" + i, new { @class = "js-switch", @checked = true })

3. script 中处理,是按钮有点击效果。

          当页面中只有一个checkbox 时:var elem = document.querySelector(".js-switch")   var switchery= new Switchery( elem,{color : '#f8ac59'}). 

          当有多个时:var elem = document.querySelector(".js-switch")  

                                $.each(funtion (num) { var switchery = new Switchery(this, { color: '#1AB394', className: 'switchery-small' });}) ;

 

 

 

 

 

 

 

 

相关文章:

  • 2022-12-23
  • 2021-11-17
  • 2021-10-26
  • 2021-08-06
  • 2021-10-08
  • 2021-09-21
  • 2021-11-13
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-03
  • 2021-04-04
  • 2021-12-25
  • 2022-12-23
相关资源
相似解决方案