I'm looking for a Javascript that makes the following: I have a list of questions with three answers each. I would like to have the following behaviour: on rollover the correct answer should change to green color. Somebody can gives me a good hint?
Example:
Question 1: how much is 2+3?
a) the correct answer is 6
b) the correct answer is 5 On rollover over the question "b) the correct answer is 5" should change to green
c) the correct answer is 4
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="language" content="english">
<meta http-equiv="Content-Style-Type" content="text/css">
<title></title>
<style type="text/css">
.correct:hover {
color:#008000;
cursor:pointer;
}
</style>
</head>
<body>
<h4>Question 1: how much is 2+3?</h4>
<p>a) the correct answer is 6</p>
<p class="correct">b) the correct answer is 5</p>
<p>c) the correct answer is 4</p>
</body>
</html>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="language" content="english">
<meta http-equiv="Content-Style-Type" content="text/css">
<title></title>
<style type="text/css">
h4 {
cursor:pointer;
}
#q1:hover~.correct {
color:#008000;
}
#q2:hover~.correct {
color:#008000;
}
</style>
</head>
<body>
<div>
<h4 id="q1">Question 1: how much is 2+3?</h4>
<p>a) the correct answer is 6</p>
<p class="correct">b) the correct answer is 5</p>
<p>c) the correct answer is 4</p>
</div>
<div>
<h4 id="q2">Question 2: how much is 2x3?</h4>
<p class="correct">a) the correct answer is 6</p>
<p>b) the correct answer is 5</p>
<p>c) the correct answer is 4</p>
</div>
</body>
</html>
coothead
Last edited by coothead; 11-19-2012 at 05:21 AM.
Reason: forgot to section the questions
Bookmarks