Underligne
Elhena
-
Gigatrappeur Messages postés 230 Statut Membre -
Gigatrappeur Messages postés 230 Statut Membre -
Bonjour, voici mon code :
Il ne marche pas, le texte entier est surligné. Ensuite je ne sais pas comment faire pour que le surlignage commence lorsqu'on appuie sur "play".
Quelqu'un a une idée ?
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Speak fast</title>
<script type="text/javascript">
var interID;
var x = 0;
var nbDiv = 6;
window.onload = function()
{
interID = setInterval(function()
{ surligne();}, 4000);
}
function surligne()
{
if (x == nbDiv) x = 0;
for (i=0; i<nbDiv; i++)
{
document.getElemntById("div"+(i+1)).style.textDecoration = "none";
}
document.getElementById("div"+(x+1)).style.textDecoration = "underligne";
x++;
}
function stop()
{ clearInterval(interID); }
</script>
</head>
<audio src="musique.mp3" controls></audio>
<body>
<div class=text id="div1">
<p style="background-color: aqua">An Australian couple have had their motorcycle stolen in south Wales</p></div>
<div class=text id="div2">
<p style="background-color: aqua">- just one day before completing their journey in London.</p></div>
<div class=text id="div3">
<p style="background-color: aqua"> Ralph Dixon, 42, and Fionnuala Livingston, 40, </p></div>
<div class=text id="div4">
<p style="background-color: aqua"> had stopped for a break on the M4 but returned to find their BMW F650 missing. </p></div>
<div class=text id="div5">
<p style="background-color: aqua"> The Sydney couple also lost gifts they had been given by people all over the world, </p></div>
<div class=text id="div6">
<p style="background-color: aqua"> and CDs containing photographs of their journey.</p></div>
</body>
</html>
Il ne marche pas, le texte entier est surligné. Ensuite je ne sais pas comment faire pour que le surlignage commence lorsqu'on appuie sur "play".
Quelqu'un a une idée ?
1 réponse
Bonjour,
c'est 2 erreurs toutes bêtes, tu as écrit :
Et :
Pour ce qui est du déclenchement sur le bouton play, tu as un évènement "play" qui existe :
http://html5doctor.com/html5-audio-the-state-of-play/#events
Tu peux l'écouter comme un autre évènement, à l'aide de addEventListener.
c'est 2 erreurs toutes bêtes, tu as écrit :
document.getElementById("div"+(x+1)).style.textDecoration = "underligne";La valeur CSS est : "underline".
Et :
document.getElemntById("div"+(i+1)).style.textDecoration = "none"; Tu as oublié un "e" dans getElementById.
Pour ce qui est du déclenchement sur le bouton play, tu as un évènement "play" qui existe :
http://html5doctor.com/html5-audio-the-state-of-play/#events
Tu peux l'écouter comme un autre évènement, à l'aide de addEventListener.