JS实现仿百度文库评分功能
作者:mrr 发布时间:2024-05-11 09:34:05
标签:js,百度文库,评分
百度文库分享平台大家都知道,今天小编通过一段实例代码给大家介绍基于js实现百度文库评分功能,先给大家展示效果图吧。
具体代码如下所示:
<!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>无标题文档</title>
<link href="http://cdn.bootcss.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
<link href="http://cdn.bootcss.com/font-awesome/4.7.0/css/font-awesome.min.css" 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] : '待评价';
}
}
</script>
</head>
<body>
<div id="content">
<span class="title"><i class="red">* </i>总体评价:</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>
<div class="tip">
<span>小提示:点击小星星可以打分</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实现仿百度文库评分功能网站的支持!
来源:http://blog.csdn.net/super_yang_android/article/details/54378477
0
投稿
猜你喜欢
- 对于如何结束一个Python程序或者用Python操作去结束一个进程等,Python本身给出了好几种方法,而这些方式也存在着一些区别,对相关
- 和朋友讨论时,我提到过一个观点,所有框架层设计中,最核心的是导航设计。最近更看到有国外同行提出“80%的可用性是导航!”因为良好的导航可以保
- 1|0使用yield完成多任务import timedef test1(): while True: print("-
- 什么是python的装饰器?网络上的定义:装饰器就是一函数,用来包装函数的函数,用来修饰原函数,将其重新赋值给原来的标识符,并永久的丧失原函
- 当有两个表,例如一个学生表,一个班级表,是多对一的关系。方法1:c = models.Class.object.get(pk=1)#查询到I
- Google Chrome 的发布,使我们更加的注重基于 WebKit 核心的浏览器的表现情况,但我们很多时候“不小心”就会出现
- 安装QT时在VS2019扩展里面下载QT工具时下载就一直卡在开始,如图: 网上搜索的一些改host和关ipv6的方法试了之后也没有
- 背景:调试服务最好的方式就是直接上机实践。对在公司的员工来说,在同一套服务上协同开发比在单独的环境上开发,应该会更有感觉。有问题可以一起发现
- 过程名:catch(str) 使用方法: 代码如下:on error resume next '你的代码,如数据库连接 call c
- 本文实例讲述了PHP接口多继承及tarits实现多继承效果的方法。分享给大家供大家参考,具体如下:接口多继承在PHP的面向对象中,接口可以继
- 前言很多时候开发者需要删除文件。可能是他错误地创建了文件,或者不再需要该文件。无论出于何种原因,都有一些方法可以通过Python来删除文件,
- 字符串Go语言中的字符串以原生数据类型出现。 Go 语言里的字符串的内部实现使用UTF-8编码。 字符串的值为双引号(")中的内容
- 本文实例讲述了Python实现批量将word转html并将html内容发布至网站的方法。分享给大家供大家参考。具体实现方法如下:#codin
- 本文实例讲述了js实现简单的可切换选项卡效果的方法。分享给大家供大家参考。具体如下:如图,最简单的纯粹的选项卡第一步,当然是先写html代码
- 前言django 的 admin 是个非常方便的admin portal,可以根据自己的需要重写.在使用Django自带的admin后台的时
- 如何做一个密码“生成器”?randompassword.asp<% Dim i, intNum,&nbs
- 什么是EfficientNet模型2019年,谷歌新出EfficientNet,在其它网络的基础上,大幅度的缩小了参数的同时提高了预测准确度
- 在Python中可以存储很大的值,如下面的Python示例程序:x = 1000000000000000000000000000000000
- 前言python中常用的写爬虫的库常有urllib2、requests,对于大多数比较简单的场景或者以学习为目的,可以用这两个库实现。这里有
- 兼容主流浏览器,独立样式表,可以很方便的进行视觉效果自定义截图:模拟下拉菜单演示代码:<!DOCTYPE html PUBLIC &q