Use jquery and CSS to create personalized radio boxes and check boxes _jquery

Source: Internet
Author: User

The image above is after the CSS and jquery beautification effect, how? Isn't it cool? This is an effect I saw from another script library, and it was pretty good, and then I realized one with jquery. For everyone to appreciate!
Say not much, directly on the code:
Copy Code code as follows:

<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
<title> Create personalized Radio boxes and check boxes </title>
<style type= "Text/css" >
*
{
margin:0;
padding:0;
font-size:12px;
}
. formt
{
width:400px;
margin:10px Auto;
border:1px solid #ccc;
height:200px;
padding:10px;
}
. unselected
{
Background-image:url (rdo_off.png);
}
. Selected
{
Background-image:url (rdo_on.png);
}
. Unchecked
{
Background-image:url (chk_off.png);
}
. checked
{
Background-image:url (chk_on.png);
}
. F_checkbox,. F_radio
{
BACKGROUND-POSITION:3PX Center;
Background-repeat:no-repeat;
Cursor:pointer;
Display:block;
height:16px;
line-height:120%;
PADDING:4PX 24px;
}
. FORMT Input
{
Left: -9999px;
Position:absolute;
}
. addcolor
{
color:red;
}
</style>
<script type= "Text/javascript" src= "Jquery-1.4.2.min.js" > </script>
<script type= "Text/javascript" >
$(
function () {
Radio
$ (". F_radio"). Click (
function () {
$ (this). AddClass ("selected"). Removeclass ("unselected"). Siblings (". Selected"). Removeclass ("selected"). AddClass ( "Unselected");
}
);
Check
$ (". F_checkbox"). Toggle (
function () {
$ (this). AddClass ("checked");
$ (this). Children ("input"). attr ("Checked", "checked");
},
function () {
$ (this). Removeclass ("checked");
$ (this). Children ("input"). Removeattr ("checked");
}
);
}
);
</script>
<body>
<div class= "FORMT" >
<label class= "F_radio unselected" >
<input type= ' Radio ' name= "height" value= "dwarf"/>
Online Tax Standard Edition </label>
<label class= "F_radio unselected" >
<input type= "Radio" name= "height" value= "average"/>
Online Tax Report Professional Edition </label>
<label class= "F_radio unselected" >
<input type= "Radio" name= "height" value= "giant"/>
Other </label>
<label class= "F_checkbox unchecked" >
<input type= "checkbox" name= "Newsletter" value= "C" id= "C"/>
Invoice Certification </label>
<label class= "F_checkbox unchecked" >
<input type= "checkbox" name= "Newsletter" value= "D" id= "D"/>
Tax-related certification </label>
</div>
<label for= "Male" >
Male</label>
<input type= "checkbox" name= "Sex" id= "male"/>
</body>

Pictures you can own screenshots.
Related Article

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.