最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

JavaScript實現(xiàn)商品評價五星好評

 更新時間:2020年11月30日 08:40:26   作者:_Yoke  
這篇文章主要為大家詳細介紹了JavaScript實現(xiàn)商品評價五星好評,文中示例代碼介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們可以參考一下

本文實例為大家分享了JavaScript實現(xiàn)商品評價五星好評的具體代碼,供大家參考,具體內(nèi)容如下

一.效果展示

二.代碼實現(xiàn)

1.html代碼

<!DOCTYPE html>
<html>
 <head>
 <meta charset="utf-8">
 <title>好評</title>
 <link rel="stylesheet" type="text/css" href="../js7/css/reset.css" />
 <link rel="stylesheet" type="text/css" href="css/myTest3.css" />
 <script type="text/javascript">
  window.onload = function(){
  ul = document.getElementById('star');
  lis = ul.getElementsByTagName('li');
  for (var i = 0; i < lis.length; i++) {
   lis[i].onclick = function(){
   //被用戶點擊后彈框并提示分數(shù)
   //獲取當前對象的對象名
   var className = this.className;//nostart
   //重新定義class,并彈出評分
   ul.className = "nostar " + className;
   var score = this.getElementsByTagName('a')[0].title;
   console.log(score);
   alert('評分:' + score);
   }
  }
  }
 </script>
 </head>
 <body>
 <ul class="nostar " id="star">
  <li class="onestar"><a title="1分"></a></li>
  <li class="twostar"><a title="2分"></a></li>
  <li class="threestar"><a title="3分"></a></li>
  <li class="fourstar"><a title="4分"></a></li>
  <li class="fivestar"><a title="5分"></a></li>
 </ul>
 </body>
</html>

2.css代碼

body{
 padding: 200px 600px;
}
.nostar{
 width: 80px;
 height: 16px;
 background: url(../img/star-matrix.gif) no-repeat;
 position: relative;
}

.nostar li {
  width: 16px;
  height: 16px;
  float: left;
  
}

.nostar li a{
   display: inline-block; 
  width: 16px;
  height: 16px; 
  position: absolute;
  /* text-indent: -999px; */ 
  /* 層級關(guān)系*/
   z-index: 10; 
}
.nostar li a:hover{
  /* 將a的大小變化 width 80 */
  left: 0px;
  width: 80px;
  background: url(../img/star-matrix.gif) no-repeat;
  z-index: 5;
}
.onestar{background-position: 0 -16px;}
.twostar{background-position: 0 -32px;}
.threestar{background-position: 0 -48px;}
.fourstar{background-position: 0 -64px;}
.fivestar{background-position: 0 -80px;}


.nostar li.onestar a:hover{ background-position: 0 -96px ;}
.nostar li.twostar a:hover{ background-position: 0 -112px ;}
.nostar li.threestar a:hover{ background-position: 0 -128px ;}
.nostar li.fourstar a:hover{ background-position: 0 -144px ;}
.nostar li.fivestar a:hover{ background-position: 0 -160px ;}

3.代碼下載

以上就是本文的全部內(nèi)容,希望對大家的學習有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

最新評論

扬中市| 盐边县| 山东| 五常市| 龙川县| 琼海市| 个旧市| 罗城| 高雄县| 西丰县| 尼勒克县| 长丰县| 通辽市| 洛川县| 浮梁县| 闵行区| 略阳县| 锡林浩特市| 太保市| 吴桥县| 垫江县| 太和县| 南陵县| 犍为县| 多伦县| 封丘县| 红桥区| 西平县| 安塞县| 无锡市| 遂宁市| 彭水| 福州市| 东乌珠穆沁旗| 获嘉县| 盘锦市| 崇仁县| 峨眉山市| 东丽区| 诏安县| 炎陵县|