ja************@yahoo.com a écrit :
Folks,
I need a working code to do the following or something similar.
I have two icons in the screen. One to indicate right (a tick mark) and
one to indicate wrong (a cross).
click what icon you want exchanges both images
<img src="ok.jpg" alt="" name="ok"
onclick="
var icon = this.src;
this.src = document.KO.src;
document.KO.src = icon;
">
<img src="X.jpg" alt="" name="KO"
onclick="
var icon = this.src;
this.src = document.ok.src;
document.ok.src = icon;
">
I would prefer :
one image (icons.jpg) with both icons
+-----+-----+
| | |
| O K | X |
| | |
+-----+-----+
CSS :
=====
..icon { cursor: pointer; }
..icon span { background: url(icons.jpg) no-repeat left center; }
..icon span.ko { background-position: right center; }
JS :
=====
function icon(what) {
what = what.getElementsByTagName('SPAN')[0];
what.className = what.className==''? 'ko' : '';
}
HTML :
======
<p class="icon" onclik="icon(this);">
<span> </span>Question 1</p>
<p class="icon" onclik="icon(this);">
<span> </span>Question 2</p>
<p class="icon" onclik="icon(this);">
<span> </span>Question 3</p>
--
Stephane Moriaux et son (moins) vieux Mac déjà dépassé
Stephane Moriaux and his (less) old Mac already out of date