本文实例为大家分享了JavaScript实现答题评分功能的具体代码,供大家参考,具体内容如下

效果图

直接上代码

HTML部分

JavaScript实现一个在线做题测试网页

在线答题

测试已开始,请开始作答,请在30分钟内完成答题
提交

CSS部分

index.css

timeTo.css

figure, figcaption {

display: block;

}

.transition {

-webkit-transition: top 400ms linear;

-moz-transition: top 400ms linear;

-ms-transition: top 400ms linear;

-o-transition: top 400ms linear;

transition: top 400ms linear;

}

.timeTo {

font-family: Tahoma, Verdana, Aial, sans-serif;

font-size: 28px;

line-height: 108%;

font-weight: bold;

height: 32px;

}

.timeTo span {

vertical-align: top;

}

.timeTo.timeTo-white div {

color: black;

background: #ffffff; /* Old browsers */

background: -moz-linear-gradient(top, #ffffff 38%, #cccccc 100%); /* FF3.6+ */

background: -webkit-gradient(linear, left top, left bottom, color-stop(38%,#ffffff), color-stop(100%,#cccccc)); /* Chrome,Safari4+ */

background: -webkit-linear-gradient(top, #ffffff 38%,#cccccc 100%); /* Chrome10+,Safari5.1+ */

background: -o-linear-gradient(top, #ffffff 38%,#cccccc 100%); /* Opera 11.10+ */

background: -ms-linear-gradient(top, #ffffff 38%,#cccccc 100%); /* IE10+ */

background: linear-gradient(to bottom, #ffffff 38%,#cccccc 100%); /* W3C */

filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#ffffff', endColorstr='#cccccc',GradientType=0 ); /* IE6-9 */

}

.timeTo.timeTo-black div {

color: white;

background: #45484d; /* Old browsers */

background: -moz-linear-gradient(top, #45484d 0%, #000000 100%); /* FF3.6+ */

background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#45484d), color-stop(100%,#000000)); /* Chrome,Safari4+ */

background: -webkit-linear-gradient(top, #45484d 0%,#000000 100%); /* Chrome10+,Safari5.1+ */

background: -o-linear-gradient(top, #45484d 0%,#000000 100%); /* Opera 11.10+ */

background: -ms-linear-gradient(top, #45484d 0%,#000000 100%); /* IE10+ */

background: linear-gradient(to bottom, #45484d 0%,#000000 100%); /* W3C */

filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#45484d', endColorstr='#000000',GradientType=0 ); /* IE6-9 */

}

.timeTo.timeTo-black .timeTo-alert {

background: #a74444; /* Old browsers */

background: -moz-linear-gradient(top, #a74444 0%, #3f0000 67%); /* FF3.6+ */

background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#a74444), color-stop(67%,#3f0000)); /* Chrome,Safari4+ */

background: -webkit-linear-gradient(top, #a74444 0%,#3f0000 67%); /* Chrome10+,Safari5.1+ */

background: -o-linear-gradient(top, #a74444 0%,#3f0000 67%); /* Opera 11.10+ */

background: -ms-linear-gradient(top, #a74444 0%,#3f0000 67%); /* IE10+ */

background: linear-gradient(to bottom, #a74444 0%,#3f0000 67%); /* W3C */

filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#a74444', endColorstr='#3f0000',GradientType=0 ); /* IE6-9 */

}

.timeTo.timeTo-white .timeTo-alert {

background: #ffffff; /* Old browsers */

background: -moz-linear-gradient(top, #ffffff 35%, #e17373 100%); /* FF3.6+ */

background: -webkit-gradient(linear, left top, left bottom, color-stop(35%,#ffffff), color-stop(100%,#e17373)); /* Chrome,Safari4+ */

background: -webkit-linear-gradient(top, #ffffff 35%,#e17373 100%); /* Chrome10+,Safari5.1+ */

background: -o-linear-gradient(top, #ffffff 35%,#e17373 100%); /* Opera 11.10+ */

background: -ms-linear-gradient(top, #ffffff 35%,#e17373 100%); /* IE10+ */

background: linear-gradient(to bottom, #ffffff 35%,#e17373 100%); /* W3C */

filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#ffffff', endColorstr='#e17373',GradientType=0 ); /* IE6-9 */

}

.timeTo figure {

display: inline-block;

margin: 0;

padding: 0;

}

.timeTo figcaption {

text-align: center;

/*font-size: 12px;*/

line-height: 80%;

font-weight: normal;

color: #888;

}

.timeTo div {

position: relative;

display: inline-block;

width: 25px;

height: 30px;

border-top: 1px solid silver;

border-right: 1px solid silver;

border-bottom: 1px solid silver;

overflow: hidden;

}

.timeTo div.first {

border-left: 1px solid silver;

}

.timeTo ul {

list-style-type: none;

margin: 0;

padding: 0;

position: absolute;

left: 3px;

}

.timeTo ul li {

margin: 0;

padding: 0;

list-style: none;

}

jquery.time-to.js部分

/**

* Time-To jQuery plug-in

* Show countdown timer or realtime clock

*

* @author Oleksii Teterin

* @version 1.3.0

* @license MIT http://opensource.org/licenses/MIT

* @date 2019-05-14

* @host https://github.com/Lexxus/jq-timeTo

*/

(function (factory) {

if (typeof define === 'function' && define.amd) {

// AMD (RequireJS)

define(['jquery'], factory);

} else if (typeof exports === 'object') {

// CommonJS (Node)

/* eslint-disable import/no-unresolved */

module.exports = factory(require('jquery'));

} else {

// globals

factory(jQuery);

}

}(function ($) {

var SECONDS_PER_DAY = 86400;

var SECONDS_PER_HOUR = 3600;

/* eslint-disable no-multi-spaces */

var defaults = {

callback: null, // callback function for exec when timer out

step: null, // callback function to exec every {stepCount} ticks

stepCount: 1, // number of ticks to increment before executing stepCount

captionSize: 0, // font-size by pixels for captions, if 0 then calculate automaticaly

countdown: true, // is countdown or real clock

countdownAlertLimit: 10, // limit in seconds when display red background

displayCaptions: false, // display captions under digit groups

displayDays: 0, // display day timer, count of days digits

displayHours: true, // display hours

fontFamily: 'Verdana, sans-serif',

fontSize: 0, // font-size of a digit by pixels (0 - use CSS instead)

lang: 'en', // language of caption

languages: {}, // extra or overridden languages

seconds: 0, // timer's countdown value in seconds

start: true, // true to start timer immediately

theme: 'white', // 'white' or 'black' theme fo timer's view

width: 25, // width of a digit area

height: 30, // height of a digit area

gap: 11, // gap size between numbers

vals: [0, 0, 0, 0, 0, 0, 0, 0, 0], // private, current value of each digit

limits: [9, 9, 9, 2, 9, 5, 9, 5, 9], // private, max value of each digit

iSec: 8, // private, index of second digit

iHour: 4, // private, index of hour digit

tickTimeout: 1000, // timeout betweet each timer tick in miliseconds

intervalId: null, // private

tickCount: 0 // private

};

var methods = {

start: function (sec) {

var intervalId;

if (sec) {

init.call(this, sec);

intervalId = setTimeout(tick.bind(this), 1000);

// save start time

this.data('ttStartTime', $.now());

this.data('intervalId', intervalId);

}

},

stop: function () {

var data = this.data();

if (data.intervalId) {

clearTimeout(data.intervalId);

this.data('intervalId', null);

}

return data;

},

reset: function (sec) {

var data = methods.stop.call(this);

var secs = typeof sec === 'undefined' ? data.seconds : sec;

this.find('div').css({ backgroundPosition: 'left center' });

this.find('ul').parent().removeClass('timeTo-alert');

init.call(this, secs, true);

}

};

var dictionary = {

en: { days: 'days', hours: 'hours', min: 'minutes', sec: 'seconds' },

ru: { days: 'дней', hours: 'часов', min: 'минут', sec: 'секунд' },

ua: { days: 'днiв', hours: 'годин', min: 'хвилин', sec: 'секунд' },

de: { days: 'Tag', hours: 'Uhr', min: 'Minuten', sec: 'Secunden' },

fr: { days: 'jours', hours: 'heures', min: 'minutes', sec: 'secondes' },

es: { days: 'días', hours: 'horas', min: 'minutos', sec: 'segundos' },

sp: { days: 'días', hours: 'horas', min: 'minutos', sec: 'segundos' },

it: { days: 'giorni', hours: 'ore', min: 'minuti', sec: 'secondi' },

nl: { days: 'dagen', hours: 'uren', min: 'minuten', sec: 'seconden' },

no: { days: 'dager', hours: 'timer', min: 'minutter', sec: 'sekunder' },

pt: { days: 'dias', hours: 'horas', min: 'minutos', sec: 'segundos' },

tr: { days: 'gün', hours: 'saat', min: 'dakika', sec: 'saniye' },

pl: { days: 'dni', hours: 'godziny', min: 'minuty', sec: 'secundy' }

};

/* eslint-enable no-multi-spaces */

if (typeof $.support.transition === 'undefined') {

$.support.transition = (function () {

var thisBody = document.body || document.documentElement;

var thisStyle = thisBody.style;

var support = thisStyle.transition !== undefined

|| thisStyle.WebkitTransition !== undefined

|| thisStyle.MozTransition !== undefined

|| thisStyle.MsTransition !== undefined

|| thisStyle.OTransition !== undefined;

return support;

}());

}

$.fn.timeTo = function () {

var options = {};

var now = Date.now();

var j, arg, num, method, time, days, tt, sec, m, t;

for (j = 0; j < arguments.length; j += 1) {

arg = arguments[j];

if (j === 0 && typeof arg === 'string') {

method = arg;

} else if (typeof arg === 'object') {

if (typeof arg.getTime === 'function') {

// arg is a Date object

options.timeTo = arg;

} else {

// arg is an options object

options = $.extend(options, arg);

}

} else if (typeof arg === 'function') {

// arg is callback

options.callback = arg;

} else {

num = parseInt(arg, 10);

// arg is seconds of timeout

if (!isNaN(num)) {

options.seconds = num;

}

}

}

// set time to countdown to

if (options.timeTo) {

if (options.timeTo.getTime) {

// set time as date object

time = options.timeTo.getTime();

} else if (typeof options.timeTo === 'number') {

// set time as integer in millisec

time = options.timeTo;

}

if (time > now) {

options.seconds = Math.floor((time - now) / 1000);

} else {

options.seconds = 0;

}

} else if (options.time || !options.seconds) {

time = options.time;

if (!time) {

time = new Date(now);

}

if (typeof time === 'object' && time.getTime) {

options.seconds = (time.getDate() * SECONDS_PER_DAY) + (time.getHours() * SECONDS_PER_HOUR) +

(time.getMinutes() * 60) + time.getSeconds();

options.countdown = false;

} else if (typeof time === 'string') {

tt = time.split(':');

sec = 0;

m = 1;

while (tt.length) {

t = tt.pop();

sec += t * m;

m *= 60;

}

options.seconds = sec;

options.countdown = false;

}

}

if (options.countdown !== false

&& options.seconds > SECONDS_PER_DAY

&& typeof options.displayDays === 'undefined') {

days = Math.floor(options.seconds / SECONDS_PER_DAY);

options.displayDays = (days < 10 && 1) || (days < 100 && 2) || 3;

} else if (options.displayDays === true) {

options.displayDays = 3;

} else if (options.displayDays) {

options.displayDays = options.displayDays > 0 ? Math.floor(options.displayDays) : 3;

}

return this.each(function () {

var $this = $(this);

var data = $this.data();

var defs, opt, i, css, language, left, ulhtml, style, dhtml1, dhtml2, dot2, maxWidth,

captionSize, fsStyleVal, fsStyle, thtml, marginRight, dhtml, $digits, dif, vals, limits;

if (data.intervalId) {

clearInterval(data.intervalId);

data.intervalId = null;

}

if (!data.vals) {

// new clock

if (data.opt) {

opt = data.options;

} else {

opt = options;

}

// clone the defaults object

defs = Object.keys(defaults).reduce(function (obj, key) {

if (Array.isArray(defaults[key])) {

obj[key] = defaults[key].slice(0);

} else {

obj[key] = defaults[key];

}

return obj;

}, {});

data = $.extend(defs, opt);

data.options = opt;

data.height = Math.round((data.fontSize * 100) / 93) || data.height;

data.width = Math.round((data.fontSize * 0.8) + (data.height * 0.13)) || data.width;

data.displayHours = !!(data.displayDays || data.displayHours);

css = {

fontFamily: data.fontFamily

};

if (data.fontSize > 0) {

css.fontSize = data.fontSize + 'px';

}

language = data.languages[data.lang] || dictionary[data.lang];

$this

.addClass('timeTo')

.addClass('timeTo-' + data.theme)

.css(css);

left = Math.round(data.height / 10);

ulhtml = '

  • 0
  • 0

';

html5 页面答题算分,JavaScript实现答题评分功能页面相关推荐

  1. html5支付宝主页面代码,JavaScript高仿支付宝倒计时页面及代码实现

    实现目标 一,页面在图一时开始进行倒计时(可以点击取消订单按钮,支付页面消失). 二,倒计时完毕,出现删除订单. 三,单击删除订单,弹出弹框,询问是否要真正删除订单. 四,单击确定,即可删除订单. 如 ...

  2. 仿百度文库html5源码,JS实现仿百度文库评分功能

    百度文库分享平台大家都知道,今天小编通过一段实例代码给大家介绍基于js实现百度文库评分功能,先给大家展示效果图吧. 具体代码如下所示: 无标题文档 *{padding:0;margin:0;} #co ...

  3. 性能优化之页面缓存(以Javascript方式缓存页面部件)

    本篇文章为大家讲解一个关于客户端缓存页面的技巧--以Javascript的方式来缓存页面的静态"部件". 如果整个页面能够被缓存到浏览器上,一个满载HTML的巨大页面也能运行地很棒 ...

  4. HTML5期末大作业:商城页面——仿优分购电商静态网页(7个页面) HTML+CSS+JavaScript 电商购物网页HTML代码 学生网页课程设计期末作业下载 大学生网页设计制作成...

    HTML5期末大作业:商城页面--仿优分购电商静态网页(7个页面) HTML+CSS+JavaScript 电商购物网页HTML代码 学生网页课程设计期末作业下载 大学生网页设计制作成 临近期末, 你 ...

  5. HTML5期末大作业:篮球网站设计(6个页面) HTML+CSS+JavaScript

    HTML5期末大作业:篮球网站设计(6个页面) HTML+CSS+JavaScript 体育网页HTML代码 学生网页课程设计期末作业下载 大学生网页设计制作成 临近期末, 你还在为HTML网页设计结 ...

  6. Java web对试卷进行单选多选答题进行打分_中考地理:简答题丢分严重,25个标准答题模板,记熟掌握拿满分!...

    哈喽,大家好!非常的感谢大家在百忙之中能够来阅读小编的文章,你们的每一次阅读都是给小编最大的创作动力,在这里小编承诺给带给大家优秀的文章,每一篇都会认认真真的去完成.今天,我们的主题是:中考地理:简答 ...

  7. 哔哩哔哩2021年1024程序员节算发与安全答题——解析答案

    哔哩哔哩2021年1024程序员节算发与安全答题 最后图片仅供参考

  8. 2021高考成绩答题卡查询,2021高考答题卡样式提前看!得分规则出炉!不看不知道,这些行为竟然让孩子丢了那么多分???避雷快看这篇文!...

    距离2021年高考仅剩两周!考生在抓紧最后时间复习的同时,务必对照规范练习答题习惯,以免因答题不规范丢分.我们为大家整理高考答题卡样式及高考答题注意事项,快快收藏! 高考答题卡样式 由于2021年各省 ...

  9. 浏览器html5/css3兼容性检测的javascript类库 - Modernizr简单介绍

    为什么80%的码农都做不了架构师?>>>    日期:2012-4-17  来源:GBin1.com 在线演示  本地下载 大家是不是在开发设计过程中遇到如下情况?某些浏览器不支持H ...

最新文章

  1. android中使用startActivityForResult回传数据
  2. [summary] 单调队列
  3. c语言告白,C语言告白代码,一闪一闪亮晶晶~
  4. css里calculate,css3 calc会计算的属性
  5. android gradle1,android studio gradle使用-(1)
  6. 关于Flex2的资料
  7. 深入理解SpringBoot配置
  8. 使用Xtrabackup来备份你的mysql
  9. __stdcall使用
  10. Java可以做什么工作
  11. 使用js实现textarea文本域长度,限制输入字数并统计剩余输入字符数
  12. 程序员,30岁+,看完让你不再焦虑
  13. arcgis for js4.x自定义图例位置添加到地图并导出
  14. MIMO技术与链路容量
  15. 房地产估值法研究报告_房地产估值方法
  16. 因为计算机丢失user32.dll,Win7系统出现无法定位动态链接库user32.dll错误提示解决方法...
  17. 不要让别人影响到你的心情
  18. java面试项目中遇到什么问题,大量教程
  19. Redis:二、Redis常见命令
  20. 【 C++11 】列表初始化、声明、范围for、STL中一些变化

热门文章

  1. 2799元起!小米CC9 Pro正式开售:1亿像素加持DXOMark总分第一
  2. 三星Galaxy Note 10最新消息:将取消所有实体按键
  3. 360金融发布城市信用排行榜:上海、苏州位列前两位
  4. 苹果全面封杀Facebook:原因不能忍
  5. 运算、函数、数组的了解
  6. 谋求“同股不同权”,旷视赴港上市渐近
  7. c语言中欧几里得模乘法逆元,扩展欧几里得算法同余方程模m乘法逆元详解
  8. 细说安防宽动态:背光补偿与二次曝光
  9. linux man使用方法 和centos安装中文man包
  10. dac生成信号频率取决于_信号发生器和DA转换 FPGA案例教程