当前位置: 移动技术网 > IT编程>开发语言>JavaScript > switchery按钮的使用方法

switchery按钮的使用方法

2018年02月22日  | 移动技术网IT编程  | 我要评论

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

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

 

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' });}) ;

以上这篇switchery按钮的使用方法就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持移动技术网。

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网