jQuery addClass example
Change class name on click in jQuery
by RoryMcCrossan
HTML
<div id="slickQuiz">
<h1 class="quizName"></h1>
<div class="quizArea">
<div class="quizHeader">
<a class="startQuiz" href="">Get Started!</a>
</div>
</div>
<div class="quizResults">
<h3 class="quizScore">You Scored: <span></span></h3>
<h3 class="quizLevel"><strong>Ranking:</strong> <span></span></h3>
<div class="quizResultsCopy"></div>
</div>
</div>
CSS
/* BASE QUIZ STYLES */
/* These styles ensure that the necessary elements are hidden for toggling */
/* DO NOT EDIT UNLESS YOU KNOW WHAT YOU ARE DOING!! */
.startQuiz,
.nextQuestion,
.backToQuestion,
.questions li.question,
.questions li.question .responses,
.questions li.question .responses .correct,
.questions li.question .responses .incorrect,
.quizResults {
display: none;
}
/* If response messages are disabled or only shown on quiz completion,
nextQuestion button IS checkAnswer button - so it must be displayed */
.nextQuestion.checkAnswer {
display: block;
}
ol.questions,
ul.answers,
ul.responses,
ol.questions li,
ul.answers li,
ul.responses li {
list-style-type: none;
}
/* Accessibility */
.quizName span:first-child {
border: 0;
clip: rect(0 0 0 0);
height: 1px;
margin: -1px;
overflow: hidden;
padding: 0;
position: absolute;
width: 1px;
}
/* QUIZ STYLES */
/* Styles to prettify the quiz page */
html {
background: #eee;
}
body {
width: 800px;
margin: 0 auto;
border: 2px solid #ccc;
border-top: none;
background: #fff;
padding: 20px;
font-family: Trebuchet, Arial,Helvetica,sans-serif;
font-size: 16px;
color: #353535;
line-height: 1.5em;
}
h1,h2,h3,h4,h5,h6 {font-weight: bold;}
h1 {
font-size: 26px;
margin: 0 0 20px;
color: #0C4569;
}
h2 {
font-size: 22px;
margin: 15px 0;
}
h3 {
font-size: 18px;
margin: 15px 0 10px;
}
h4 {
font-size: 16px;
margin: 10px 0;
}
h5 {
font-size: 14px;
margin: 10px 0 5px;
}
h6 {
font-size: 12px;
margin: 5px 0;
}
strong { font-weight: bold; }
em { font-style: italic; }
ul { list-style-type: circle; }
ol { list-style-type: decimal; }
ol li { list-style-type: decimal; margin-left: 20px; }
.button {
float: left;
width: auto;
padding: 5px 15px;
color:#ffffff;
background-color:darkcyan;
border: 1px solid #fff;
-webkit-border-radius: 5px;
-moz-border-radius:...
JavaScript
/*!
* SlickQuiz jQuery Plugin
* https://github.com/jewlofthelotus/SlickQuiz
*
* @updated October 25, 2014
* @version 1.5.20
*
* @author Julie Cameron - http://www.juliecameron.com
* @copyright (c) 2013 Quicken Loans - http://www.quickenloans.com
* @license MIT
*/
(function($) {
$.slickQuiz = function(element, options) {
var plugin = this,
$element = $(element),
_element = '#' + $element.attr('id'),
defaults = {
checkAnswerText: 'Check My Answer!',
nextQuestionText: 'Next »',
backButtonText: '',
completeQuizText: '',
tryAgainText: '',
questionCountText: 'Question %current of %total',
preventUnansweredText: 'You must select at least one answer.',
questionTemplateText: '%count. %text',
scoreTemplateText: '%score / %total',
nameTemplateText: '<span>Quiz: </span>%name',
skipStartButton: false,
numberOfQuestions: null,
randomSortQuestions: false,
randomSortAnswers: false,
preventUnanswered: false,
disableScore: false,
disableRanking: false,
scoreAsPercentage: false,
perQuestionResponseMessaging: true,
perQuestionResponseAnswers: false,
completionResponseMessaging: false,
displayQuestionCount: true, // Deprecate?
displayQuestionNumber: true, // Deprecate?
animationCallbacks: { // only for the methods that have jQuery animations offering callback
setupQuiz: function() {},
startQuiz: function() {},
resetQuiz: function() {},
checkAnswer: function() {},
nextQuestion: function() {},
backToQuestion: function() {},
completeQuiz: function() {}
},
events: {
onStartQuiz: function(options) {},
onCompleteQuiz: function(options) {} // reserved: options.questionCount, options.score
}
},
// Class Name Strings (Used for building...