JS實(shí)現(xiàn)仿百度文庫(kù)評(píng)分功能
百度文庫(kù)分享平臺(tái)大家都知道,今天小編通過(guò)一段實(shí)例代碼給大家介紹基于js實(shí)現(xiàn)百度文庫(kù)評(píng)分功能,先給大家展示效果圖吧。

具體代碼如下所示:
<!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>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>無(wú)標(biāo)題文檔</title>
<link rel="stylesheet">
<link rel="stylesheet">
<style>
*{padding:0;margin:0;}
#content{width:700px;height:50px;border:1px solid #ccc;margin:50px auto;line-height:50px;}
#content span.title{display:line-block;width:100px;height:50px;line-height:50px;font-size:20px;font-weight:bold;color:#FF9933;}
#content ul.stars {display:inline-block;width:160px;height:50px;line-height:50px;cursor:pointer;}
#content ul.stars li {font-size:30px;color:#ccc;}
#content p {display:inline-block;width:80px;height:50px;line-height:50px;font-size:20px;font-weight:bold;color:#ff9933;}
#content .tip{display:inline-block;height:45px;border:1px #ccc red;background:#FFFFCC; visibility:hidden;}
#content .tip span {display:inline-block;height:40px;line-height:40px;padding:0px 10px;;}
#content .tip ul {display:inline-block;position:relative;}
#content .tip ul i{position:absolute;top:70%;right:18%;}
.red {color:red;margin-left:10px;}
.orange{color:orange;}
</style>
<script>
window.onload = function () {
var content = document.getElementById('content');
var score = document.getElementById('score');
var oUl = content.getElementsByClassName('stars')[0];
var aLi = oUl.getElementsByTagName('li');
var tip = content.getElementsByClassName('tip')[0];
var arr = ['較差','較差','還行','推薦','力薦'];
oUl.onmouseover = function(){
tip.style.visibility = 'visible';
}
oUl.onmouseout = function(){
tip.style.visibility = 'hidden';
}
for( var i=0;i<aLi.length;i++ ){
aLi[i].index = i;
aLi[i].onclick = function () {
mark(this.index);
oUl.index = this.index;
}
aLi[i].onmouseover = function(){
for( var i=0;i<aLi.length;i++ ){
aLi[i].style.color = '#ccc';
}
mark(this.index);
}
aLi[i].onmouseout = function(){
for( var i=0;i<=this.index;i++ ){
aLi[i].style.color = '#ccc';
}
if(oUl.index !== 'undefined'){
mark(parseInt(oUl.index));
}
}
}
function show() {
tip.style.visibility = tip.style.visibility === 'hidden' ? 'visible' : 'hidden';
}
function mark(index) {
for( var i=0;i<=index;i++ ){
aLi[i].style.color = index < 2 ? 'gray' : 'orange';
}
score.innerHTML = arr[index] ? arr[index] : '待評(píng)價(jià)';
}
}
</script>
</head>
<body>
<div id="content">
<span class="title"><i class="red">* </i>總體評(píng)價(jià):</span>
<ul class="stars">
<li class="fa fa-star"></li>
<li class="fa fa-star"></li>
<li class="fa fa-star"></li>
<li class="fa fa-star"></li>
<li class="fa fa-star"></li>
</ul>
<p id="score">待評(píng)價(jià)</p>
<div class="tip">
<span>小提示:點(diǎn)擊小星星可以打分</span>
<ul>
<li class="fa fa-star orange"></li>
<li class="fa fa-star orange"></li>
<li class="fa fa-star orange"></li>
<li class="fa fa-star orange"></li>
<li class="fa fa-star-o"></li>
<i class="fa fa-hand-pointer-o"></i>
</ul>
</div>
</div>
</body>
</html>
以上所述是小編給大家介紹的JS實(shí)現(xiàn)仿百度文庫(kù)評(píng)分功能,希望對(duì)大家有所幫助,如果大家有任何疑問(wèn)請(qǐng)給我留言,小編會(huì)及時(shí)回復(fù)大家的。在此也非常感謝大家對(duì)腳本之家網(wǎng)站的支持!
- js仿淘寶和百度文庫(kù)的評(píng)分功能
- PHP實(shí)現(xiàn)仿百度文庫(kù),豆丁在線文檔效果(word,excel,ppt轉(zhuǎn)flash)
- pdf2swf+flexpapers實(shí)現(xiàn)類似百度文庫(kù)pdf在線閱讀
- 將word轉(zhuǎn)化為swf 如同百度文庫(kù)般閱讀實(shí)現(xiàn)思路及代碼
- 用python下載百度文庫(kù)的代碼
- java實(shí)現(xiàn)附件預(yù)覽(openoffice+swftools+flexpaper)實(shí)例
- Java仿文庫(kù)的基本方法(openoffice+swftools+flexPaper)
相關(guān)文章
用JS寫一段判斷搜索引擎來(lái)路并且屏蔽PC的跳轉(zhuǎn)代碼
以下是用JS寫的判斷搜索引擎來(lái)路并屏蔽PC跳轉(zhuǎn)的代碼,需要的朋友可以參考下2023-12-12
JavaScript如何動(dòng)態(tài)創(chuàng)建table表格
這篇文章主要介紹了JavaScript如何動(dòng)態(tài)創(chuàng)建table表格,一些時(shí)候需要?jiǎng)討B(tài)的創(chuàng)建和刪除表格,接下來(lái)的文章中將為大家介紹下javascript是如何做到的,感興趣的朋友不要錯(cuò)過(guò)2015-11-11
js 無(wú)提示關(guān)閉瀏覽器頁(yè)面的代碼
js 無(wú)提示關(guān)閉瀏覽器頁(yè)面的代碼與函數(shù)需要的朋友可以參考下。2010-03-03
完美解決IE9瀏覽器出現(xiàn)的對(duì)象未定義問(wèn)題
下面小編就為大家?guī)?lái)一篇完美解決IE9瀏覽器出現(xiàn)的對(duì)象未定義問(wèn)題。小編覺(jué)得挺不錯(cuò)的,現(xiàn)在就分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧,祝大家游戲愉快哦2016-09-09
JS實(shí)現(xiàn)將人民幣金額轉(zhuǎn)換為大寫的示例代碼
本篇文章主要是對(duì)使用JS實(shí)現(xiàn)將人民幣金額轉(zhuǎn)換為大寫的示例代碼進(jìn)行了介紹,需要的朋友可以過(guò)來(lái)參考下,希望對(duì)大家有所幫助2014-02-02

