Using Jqmobi to develop the app base toggle switches Switch button

Source: Internet
Author: User
Tags switches

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.