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)文章
Pro JavaScript Techniques學(xué)習(xí)筆記
Pro JavaScript Techniques學(xué)習(xí)筆記,學(xué)習(xí)js的朋友可以參考下。2010-12-12解決BootStrap Fileinput手機(jī)圖片上傳顯示旋轉(zhuǎn)問(wèn)題
這篇文章主要介紹了 BootStrap Fileinput手機(jī)圖片上傳顯示旋轉(zhuǎn)問(wèn)題,需要的朋友可以參考下2017-06-06JS實(shí)現(xiàn)隨機(jī)顏色的3種方法與顏色格式的轉(zhuǎn)化
隨機(jī)顏色和顏色格式是我們?cè)陂_(kāi)發(fā)中經(jīng)常要用到的一個(gè)小功能,網(wǎng)上相關(guān)的資料也很多,想著有必要總結(jié)一下自己的經(jīng)驗(yàn)。所以這篇文章主要介紹了JS實(shí)現(xiàn)隨機(jī)顏色的3種方法與顏色格式的轉(zhuǎn)化,需要的朋友可以參考借鑒,下面來(lái)一起看看吧。2017-01-01TypeScript創(chuàng)建一個(gè)簡(jiǎn)單Web應(yīng)用
這篇文章主要為大家介紹了TypeScript創(chuàng)建一個(gè)簡(jiǎn)單Web應(yīng)用,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪2022-05-05原生Js實(shí)現(xiàn)簡(jiǎn)易煙花爆炸效果的方法
這篇文章主要介紹了原生Js實(shí)現(xiàn)簡(jiǎn)易煙花爆炸效果的方法,實(shí)例分析了javascript實(shí)現(xiàn)煙花爆炸效果的原理與具體實(shí)現(xiàn)方法,具有一定參考借鑒價(jià)值,需要的朋友可以參考下2015-03-03深入理解JavaScript系列(35):設(shè)計(jì)模式之迭代器模式詳解
這篇文章主要介紹了深入理解JavaScript系列(35):設(shè)計(jì)模式之迭代器模式詳解,迭代器模式(Iterator):提供一種方法順序一個(gè)聚合對(duì)象中各個(gè)元素,而又不暴露該對(duì)象內(nèi)部表示,需要的朋友可以參考下2015-03-03JavaScript實(shí)現(xiàn)環(huán)繞鼠標(biāo)旋轉(zhuǎn)效果
這篇文章主要為大家詳細(xì)介紹了JavaScript實(shí)現(xiàn)環(huán)繞鼠標(biāo)旋轉(zhuǎn)效果,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2022-01-01