您的位置:首页 > Web前端 > JQuery

Jquery easyui switchbutton简单使用 .

2016-08-19 17:15 387 查看
刚刚做完switchbutton这个的简单的功能,下面说说最使用的几点。html
<div class="state"><input class="easyui-switchbutton" onText="开" offText="关" name="unitState"></div>
onText=“”和offText=“”就是设置里面的文字,为了下面js使用,起个name
.switchbutton-on { background: #EAF2FF; color: #000000; }  /*开时的样式*/
.switchbutton-off { background: #E1E1E1; color: #000000; } /*关时的样式*/
这个class类设置开关样式。注意引用css顺序,无论什么框架,先引用框架的css和js,再引用自己的css和js。这样自定义的css和js就能覆盖框架的,各位看官切记!说道这,有些框架的样式改不掉,js都不能覆盖,尝试在css样式后面添加!important试试。
.clear { clear: both !important; }
像这样,只要我们的css在框架的css之后被加载,一般都会覆盖框架的css。
var thisSwitchbuttonObj = $(".state").find("[switchbuttonName='unitState']");//获取switchbutton对象var unitState = true;//是否选中的值
if(unitState){thisSwitchbuttonObj.switchbutton("check");}if(!unitState){thisSwitchbuttonObj.switchbutton("uncheck");}
初始化按钮。
var thisValue = thisSwitchbuttonObj.switchbutton("options").checked;
获取按钮的返回值,返回值类型:true或者false。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  easyui switchbutton