Switch buttons are often used in app development. The display effect is as follows:
It is also simple to implement in Jqmobi.
To implement the effect code above:
<div>
<label>
Remember password </label><input id= "forgetpwd" type= "checkbox" Name= "Forgetpwd" Value= "1" class= "toggle" ><label for= "forgetpwd"
data-on= "on" data-off= "Off" ><span></span ></label><br/>
<label>
automatic login </label><input id= "outologin" type= "checkbox" Name= "Outologin" value= "0" class= "toggle" ><label for= "Outologin
" data-on= "on" data-off= "Off" ><span ></span></label>
</div>
Back to the column page: http://www.bianceng.cnhttp://www.bianceng.cn/OS/extra/
The key is to give radio or checkbox. Use the class attribute toggle and add a label label that corresponds to the label label's for property with the name of the radio or checkbox, using data-on to set the text that appears when selected, and using Data-off to set no selection of the text. A span label must be added in the middle of the label.
Determine whether the selected method:
such as the code above, to determine whether to remember the password
Instead of using attr, or Val, you should use the Prop method
Test code:
Alert ($ ("#forgetPwd"). attr ("checked");
Alert ($ ("#forgetPwd"). Prop ("checked");
Alert ($ ("#forgetPwd"). Val ());
$ ("#forgetPwd"). attr ("Checked"), $ ("#forgetPwd"). Val () is always the same, only $ ("#forgetPwd"). Prop ("checked") is changed.
When selected $ ("#forgetPwd"). Prop ("Checked") is true, otherwise false.
Author: csdn Blog xuexiaodong2009