Jquery easyui switchbutton简单使用

刚刚做完switchbutton这个的简单的功能,下面说说最使用的几点。

html


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。

简单的案例

你可能感兴趣的:(Jquery easyui switchbutton简单使用)