用jquery與css打造個(gè)性化的單選框和復(fù)選框
更新時(shí)間:2010年10月20日 10:46:09 作者:
利用jquery和css打造個(gè)性化的單選框和復(fù)選框,喜歡的朋友可以參考下。

上圖是經(jīng)過css和jquery美化后的效果,怎么樣呢?是不是很爽啊!這個(gè)是我從另一個(gè)腳本庫看到的一個(gè)效果,覺得挺不錯(cuò)的,然后就用jquery自己實(shí)現(xiàn)了一個(gè)。供大家鑒賞!
話不多說,直接上代碼:
復(fù)制代碼 代碼如下:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>打造個(gè)性化的單選框和復(fù)選框</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 () {
//單選
$(".f_radio").click(
function () {
$(this).addClass("selected").removeClass("unselected").siblings(".selected").removeClass("selected").addClass("unselected");
}
);
//復(fù)選
$(".f_checkbox").toggle(
function () {
$(this).addClass("checked");
$(this).children("input").attr("checked", "checked");
},
function () {
$(this).removeClass("checked");
$(this).children("input").removeAttr("checked");
}
);
}
);
</script>
</head>
<body>
<div class="formt">
<label class="f_radio unselected">
<input type='radio' name="height" value="dwarf" />
網(wǎng)上辦稅標(biāo)準(zhǔn)版</label>
<label class="f_radio unselected">
<input type="radio" name="height" value="average" />
網(wǎng)上報(bào)稅專業(yè)版</label>
<label class="f_radio unselected">
<input type="radio" name="height" value="giant" />
其他</label>
<hr />
<label class="f_checkbox unchecked">
<input type="checkbox" name="newsletter" value="c" id="c" />
發(fā)票認(rèn)證</label>
<label class="f_checkbox unchecked">
<input type="checkbox" name="newsletter" value="d" id="d" />
涉稅認(rèn)證</label>
</div>
<label for="male">
Male</label>
<input type="checkbox" name="sex" id="male" />
</body>
</html>
圖片大家可以自己截圖。
您可能感興趣的文章:
- jquery 操作單選框,復(fù)選框,下拉列表實(shí)現(xiàn)代碼
- 推薦11款jQuery開發(fā)的復(fù)選框和單選框美化插件
- Jquery為單選框checkbox綁定單擊click事件
- JQUERY對(duì)單選框(radio)操作的小例子
- jquery操作下拉列表、文本框、復(fù)選框、單選框集合(收藏)
- jquery單選框radio綁定click事件實(shí)現(xiàn)方法
- JQuery判斷radio(單選框)是否選中和獲取選中值方法總結(jié)
- jQuery實(shí)現(xiàn)按鈕的點(diǎn)擊 全選/反選 單選框/復(fù)選框 文本框 表單驗(yàn)證
- Labelauty–jQuery單選框/復(fù)選框美化插件分享
相關(guān)文章
Jquery針對(duì)tr td的一些實(shí)用操作方法(必看篇)
下面就為大家?guī)硪黄狫query針對(duì)tr td的一些實(shí)用操作方法(必看篇)。小編覺得挺不錯(cuò)的,現(xiàn)在就分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧2016-10-10
jquery實(shí)現(xiàn)橫向圖片輪播特效代碼分享
這篇文章主要介紹了jquery實(shí)現(xiàn)橫向圖片輪播特效代碼,效果很精致,實(shí)現(xiàn)方法很簡單,特推薦給大家,希望大家可以喜歡。2015-11-11
jQuery實(shí)現(xiàn)簡單的tab標(biāo)簽頁效果
這篇文章主要介紹了jQuery實(shí)現(xiàn)簡單的tab標(biāo)簽頁效果,涉及jQuery簡單元素遍歷與樣式動(dòng)態(tài)操作相關(guān)技巧,需要的朋友可以參考下2016-09-09
推薦40款強(qiáng)大的 jQuery 導(dǎo)航插件和教程(上篇)
在下面的集合中,你會(huì)發(fā)現(xiàn)很多便利的 jQuery 導(dǎo)航插件和有用的教程,幫助你實(shí)現(xiàn)充滿吸引力的網(wǎng)站導(dǎo)航,讓你網(wǎng)站更有組織性和交互性2012-09-09
jQGrid動(dòng)態(tài)填充select下拉框的選項(xiàng)值(動(dòng)態(tài)填充)
這篇文章主要介紹了jQGrid動(dòng)態(tài)填充select下拉框的選項(xiàng)值(動(dòng)態(tài)填充)的相關(guān)資料,非常不錯(cuò),具有參考借鑒價(jià)值,需要的朋友可以參考下2016-11-11
jquery實(shí)現(xiàn)表單輸入時(shí)提示文字滑動(dòng)向上效果
這篇文章主要介紹了jquery實(shí)現(xiàn)表單輸入時(shí)提示文字滑動(dòng)向上效果,涉及jquery鼠標(biāo)事件響應(yīng)及頁面元素樣式的動(dòng)態(tài)操作技巧,具有一定參考借鑒價(jià)值,需要的朋友可以參考下2015-08-08

