Appliquer un code javascript sur plusieurs id

Fermé
Profil bloqué - 20 sept. 2013 à 20:01
 Profil bloqué - 20 sept. 2013 à 20:21
bonjour à tous !

Je demande votre aide pour appliquer mon code javascript sur plusieurs div, on m'a dit qu'il fallait que je me serve d'une boucle mais je ne sais pas laquelle. Le souci est que je puisse ouvrir mes DEUX div au survol.

voici le code css:

#la_div{
height:18px;
width:900px;
border:1px solid black;
border-radius:5px;
overflow:hidden;
}
#la_div h1{
margin:0px;
line-height:18px;
font-size:16px;
}
#la_div #bouton_lecture{
margin:auto;
position:relative;
}

voici le code html:

<div id="la_div">
<h1> Changer le volume d'une chanson et l'exporter en mp3</h1>
<iframe id="la_video" frameborder="0" height="506" src="https://www.youtube.com/embed/1cefBcHaz_U" width="900px"></iframe>
<img id="bouton_lecture" src="https://12a14af8-a-62cb3a1a-s-sites.googlegroups.com/site/resolutionrubikscube3x3x3/boutonlecture.png?attachauth=ANoY7cq0eDvazQGl9LC8bLQZvV4WkiJE8DAUaE1q3XNAi0QNNvb6cpXmGfumq_xBTrHW34JCIeAumrDQTOVR_CZ_DxMBWgdxap0bIhyb-oiUzZfBi7ebDSk-VQKYaTFR1Ryiaw305awo3Y8_WqLQ0rVwlgtSwzTgY82zZLOCTEZ18Njc7xvzO14RpShyNvcpSOZVba9Ajkm_nbVMb8LEuSbb6KTNw_ey59IBQtost5LsbAqEOhpqi_g%3D&attredirects=2"></img>
</div>
<br />
<div id="la_div">
<h1> Exemple</h1>
<iframe id="la_video" frameborder="0" height="506" src="https://www.youtube.com/embed/RFHEA54RXTI" width="900px"></iframe>
<img id="bouton_lecture" src="https://12a14af8-a-62cb3a1a-s-sites.googlegroups.com/site/resolutionrubikscube3x3x3/boutonlecture.png?attachauth=ANoY7cq0eDvazQGl9LC8bLQZvV4WkiJE8DAUaE1q3XNAi0QNNvb6cpXmGfumq_xBTrHW34JCIeAumrDQTOVR_CZ_DxMBWgdxap0bIhyb-oiUzZfBi7ebDSk-VQKYaTFR1Ryiaw305awo3Y8_WqLQ0rVwlgtSwzTgY82zZLOCTEZ18Njc7xvzO14RpShyNvcpSOZVba9Ajkm_nbVMb8LEuSbb6KTNw_ey59IBQtost5LsbAqEOhpqi_g%3D&attredirects=2"></img>
</div>

Voici le code javascript:

var Div = document.getElementById('la_div');
var Video = document.getElementById('la_video');
var BTL = document.getElementById('bouton_lecture');

Div.style.cssText = 'transition:height 1s;-moz-transition:height 1s;-webkit-transition:height 1s;-o-transition:height 1s;';
Video.style.display = '';
BTL.style.display = '';

BTL.onclick = function(){
BTL.flag = true;
BTL.style.visibility='hidden';
};
Div.onmouseover = function(){
this.style.height = '524px';

BTL.style.height = '506px';
BTL.style.width = '900px';
BTL.style.bottom = '505px';
BTL.style.left = '0px';
BTL.style.cursor = 'pointer';
};
Div.onmouseout = function(){
if( !BTL.flag){
this.style.height = '18px';
}
};

Merci de votre réponse.
A voir également:

2 réponses

ryko1820 Messages postés 1677 Date d'inscription dimanche 28 avril 2013 Statut Membre Dernière intervention 15 août 2021 276
20 sept. 2013 à 20:18
Déjà normalement je crois que tu n'a pas le droit d'utiliser 2 div id de même nom.
Je pense que c'est pour ça qu'on t'a dit que tu pourrais utiliser une boucle en les appelant par exemple la_div1, la_div2 ensuite dans une boucle for tu reconstitues le nom de ton id ...

Me suis pas trop penché sur ton code non plus ...
0
Merci mais la vraie question est COMMENT faire ça ???

Pito2901
0