欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

javascript實(shí)現(xiàn)checkbox復(fù)選框?qū)嵗a

 更新時間:2016年01月10日 11:23:13   投稿:lijiao  
這篇文章主要為大家介紹了javascript實(shí)現(xiàn)checkbox復(fù)選框?qū)嵗a,對checkbox復(fù)選框進(jìn)行美化,感興趣的小伙伴們可以參考一下

本文實(shí)例介紹了javascript實(shí)現(xiàn)checkbox復(fù)選框?qū)嵗a以及對checkbox復(fù)選框進(jìn)行美化操作,分享給大家供大家參考,具體內(nèi)容如下

1、checkbox復(fù)選框進(jìn)行美化操作

復(fù)選框默認(rèn)外表的美觀度差強(qiáng)人意,能夠滿足美觀度要求不高的頁面,但是如果對于頁面要求較為精致,那可能就過于勉強(qiáng)了,下面就一段對復(fù)選框進(jìn)行美化的代碼實(shí)例,希望能夠給大家?guī)硪欢ǖ膸椭?br /> 代碼實(shí)例如下:

<!DOCTYPE html>
<html>
<head>
<meta charset=" utf-8">
<title>checkbox復(fù)選框</title>
<style type="text/css">
.CheckBoxClass{display:none;}
.CheckBoxLabelClass{
 background:url("mytest/jQuery/UnCheck.png") no-repeat;
 padding-left:30px;
 padding-top:3px;
 margin:5px;
 height:28px;
 width:150px;
 display:block;
}
.CheckBoxLabelClass:hover{text-decoration:underline;}
.LabelSelected{background:url("mytest/jQuery/Check.png") no-repeat;}
</style>
<script type="text/javascript" src="mytest/jQuery/jquery-1.8.3.js"></script>
<script type="text/javascript">
$(document).ready(function(){
 $(".CheckBoxClass").change(function(){
  if($(this).is(":checked")){
   $(this).next("label").addClass("LabelSelected");
  }
  else{
   $(this).next("label").removeClass("LabelSelected");
  }
 });
})
</script>
</head>
<body>
<div>
 <input id="CheckBox1" type="checkbox" class="CheckBoxClass"/>
 <label id="Label1" for="CheckBox1" class="CheckBoxLabelClass">腳本之家一</label>
 <input id="CheckBox2" type="checkbox" class="CheckBoxClass"/>
 <label id="Label2" for="CheckBox2" class="CheckBoxLabelClass">腳本之家二</label>
</div>
</body>
</html>

2、checkbox復(fù)選框全選和取消全選實(shí)例代碼
關(guān)于復(fù)選框的全選和不全選是非常常見的操作,本章節(jié)分享一段代碼實(shí)例,能夠?qū)崿F(xiàn)多種選中和取消選中功能。
代碼實(shí)例如下:

<!DOCTYPE html>
<html>
<head>
<meta charset=" utf-8">
<title>腳本之家</title>
<script type="text/javascript" src="mytest/jQuery/jquery-1.8.3.js"></script> 
<script type="text/javascript">
$("document").ready(function(){
 $("#all").click(function(){  
  if(this.checked)
  {  
   $("input[name='checkbox']").each(function(){this.checked=true;});
   $("#btn1").attr("value","反選");  
  }
  else
  {  
   $("input[name='checkbox']").each(function(){this.checked=false;});  
   $("#btn1").attr("value","全選"); 
  }  
 }); 
 
 $("#btn1").click(function(){
  $("[name='checkbox']").attr("checked",'true');
 })
  
 $("#cancel").click(function(){
  $("[name='checkbox']").removeAttr("checked");
 })
  
 $("#jishu").click(function(){
  $("[name='checkbox']:even").attr("checked",'true');
 })
  
 $("#fanxuan").click(function(){
  $("[name='checkbox']").each(function(){
   if($(this).attr("checked"))
   {
    $(this).removeAttr("checked");
   }
   else
   {
    $(this).attr("checked",'true');
   }
  })
 })
 $("#get").click(function(){
  var str="";
  $("[name='checkbox'][checked]").each(function(){
   str+=$(this).val()+"/r/n";
  })
  alert(str);
 })
})
 </script>
 </head>
 <body>
 <form name="form1" method="post" action="">
  <input type="checkbox" id="all" name="all">
  <input type="button" id="btn1" value="全選">
  <input type="button" id="cancel" value="取消全選">
  <input type="button" id="jishu" value="選中所有奇數(shù)">
  <input type="button" id="fanxuan" value="反選">
  <input type="button" id="get" value="獲得選中的所有值">
  <br>
  <input type="checkbox" name="checkbox" value="腳本之家一">
  腳本之家一
  <input type="checkbox" name="checkbox" value="腳本之家二">
  腳本之家二
  <input type="checkbox" name="checkbox" value="腳本之家三">
  腳本之家三
  <input type="checkbox" name="checkbox" value="腳本之家四">
  腳本之家四
  <input type="checkbox" name="checkbox" value="腳本之家五">
  腳本之家五
  <input type="checkbox" name="checkbox" value="腳本之家六">
  腳本之家六
  <input type="checkbox" name="checkbox" value="腳本之家七">
  腳本之家七
  <input type="checkbox" name="checkbox" value="腳本之家八">
  腳本之家八
 </form>
</body>
</html> 

以上就是關(guān)于checkbox復(fù)選框的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助。

相關(guān)文章

  • JS for循環(huán)中i++ 和 ++i的區(qū)別介紹

    JS for循環(huán)中i++ 和 ++i的區(qū)別介紹

    這篇文章主要介紹了JS for循環(huán)中i++ 和 ++i的區(qū)別介紹的相關(guān)資料,需要的朋友可以參考下
    2016-07-07
  • javascript圖片預(yù)加載實(shí)例分析

    javascript圖片預(yù)加載實(shí)例分析

    這篇文章主要介紹了javascript圖片預(yù)加載的方法,實(shí)例分析了javascript實(shí)現(xiàn)圖片預(yù)加載的方法與相關(guān)注意事項,具有一定參考借鑒價值,需要的朋友可以參考下
    2015-07-07
  • js css 實(shí)現(xiàn)遮罩層覆蓋其他頁面元素附圖

    js css 實(shí)現(xiàn)遮罩層覆蓋其他頁面元素附圖

    實(shí)現(xiàn)遮罩層的方法有很多,但大多都是使用js css來實(shí)現(xiàn)的,本例也實(shí)現(xiàn)一個,效果還不錯,喜歡的朋友可以感受下
    2014-09-09
  • js如何改變文章的字體大小

    js如何改變文章的字體大小

    這篇文章主要介紹了js改變文章字體大小的方法,大家在使用word文檔時工具欄為大家提供更改字體大小的選項,那js是如何改變文章字體大小,下文為大家揭曉,需要的朋友可以參考下
    2016-01-01
  • 微信小程序使用navigator實(shí)現(xiàn)頁面跳轉(zhuǎn)功能

    微信小程序使用navigator實(shí)現(xiàn)頁面跳轉(zhuǎn)功能

    本周學(xué)習(xí)了navigtor到導(dǎo)航組件,目前我想使用navigtor組件實(shí)現(xiàn)跳轉(zhuǎn)以及返回功能,下面這篇文章主要給大家介紹了關(guān)于微信小程序使用navigator實(shí)現(xiàn)頁面跳轉(zhuǎn)功能的相關(guān)資料,文中通過實(shí)例代碼介紹的非常詳細(xì),需要的朋友可以參考下
    2022-08-08
  • webpack動態(tài)加載與打包方式

    webpack動態(tài)加載與打包方式

    webpack有兩種組織模塊依賴的方式,同步和異步,這篇文章主要介紹了webpack動態(tài)加載與打包方式,本文結(jié)合實(shí)例代碼給大家介紹的非常詳細(xì),需要的朋友可以參考下
    2023-02-02
  • JavaScript操作class和style樣式代碼詳解

    JavaScript操作class和style樣式代碼詳解

    這篇文章主要介紹了JavaScript操作class和style樣式的相關(guān)資料,需要的朋友可以參考下
    2016-02-02
  • 簡單實(shí)現(xiàn)輪播圖效果的實(shí)例

    簡單實(shí)現(xiàn)輪播圖效果的實(shí)例

    下面小編就為大家?guī)硪黄唵螌?shí)現(xiàn)輪播圖效果的實(shí)例。小編覺得挺不錯的,現(xiàn)在就分享給大家,也給大家做個參考。一起跟隨小編過來看看吧
    2016-07-07
  • 微信小程序天氣預(yù)報功能實(shí)現(xiàn)(支持自動定位,附源碼)

    微信小程序天氣預(yù)報功能實(shí)現(xiàn)(支持自動定位,附源碼)

    對于一個經(jīng)常出門在外的人,關(guān)注天氣是至關(guān)重要的,下面這篇文章主要給大家介紹了關(guān)于微信小程序天氣預(yù)報功能實(shí)現(xiàn)的相關(guān)資料,文中通過實(shí)例代碼介紹的非常詳細(xì),支持自動定位,需要的朋友可以參考下
    2022-04-04
  • javascript計算用戶打開網(wǎng)頁的停留時間

    javascript計算用戶打開網(wǎng)頁的停留時間

    本文介紹了javascript計算用戶打開網(wǎng)頁的停留時間,大家參考使用吧
    2014-01-01

最新評論