Forum |  HardWare.fr | News | Articles | PC | S'identifier | S'inscrire | Shop Recherche
5879 connectés 

  FORUM HardWare.fr
  Programmation
  HTML/CSS

  getElementById

 


 Mot :   Pseudo :  
 
Bas de page
Auteur Sujet :

getElementById

n°1185076
zizou771
http://mobiles.forumpro.fr
Posté le 26-08-2005 à 12:01:33  profilanswer
 

slt,
j'utilise getElementById pour modifier des div.
or je veux modifier toutes mes div( qui portes toutes le meme Id)
et getElementById ne me modifie que la 1ere.
comment cela ce fait t-il
si quelqu'un peut m'eclaircir?!?
 
merci d'avance

mood
Publicité
Posté le 26-08-2005 à 12:01:33  profilanswer
 

n°1185081
masklinn
í dag viðrar vel til loftárása
Posté le 26-08-2005 à 12:03:19  profilanswer
 

zizou771 a écrit :

toutes mes div( qui portes toutes le meme Id)


Un ID est un identifiant unique d'un objet sur une page, deux objets de la même page ne peuvent pas légalement porter le même ID


---------------
I mean, true, a cancer will probably destroy its host organism. But what about the cells whose mutations allow them to think outside the box by throwing away the limits imposed by overbearing genetic regulations? Isn't that a good thing?
n°1185093
zizou771
http://mobiles.forumpro.fr
Posté le 26-08-2005 à 12:06:58  profilanswer
 

ben les miens si, il sont crée comme ca
sinon y a getElementByName mais ca marche pas apparement?!?

n°1185118
masklinn
í dag viðrar vel til loftárása
Posté le 26-08-2005 à 12:15:26  profilanswer
 

zizou771 a écrit :

ben les miens si, il sont crée comme ca


...
 
Ok, maintenant tu démarres les neurones 5 secondes, tu relis ma phrase et tu te dis que c'est peut être parce que tu tentes de faire un truc illégal que ça fonctionne pas [:itm]

Citation :

sinon y a getElementByName mais ca marche pas apparement?!?


[:petrus75]
 
non, ya pas getElementByName [:petrus75]
 
Il y a getElementsByName, qui est déprécié et n'est plus censé être utilisé, et getElementsByTagName  [:petrus75]


---------------
I mean, true, a cancer will probably destroy its host organism. But what about the cells whose mutations allow them to think outside the box by throwing away the limits imposed by overbearing genetic regulations? Isn't that a good thing?
n°1185130
zizou771
http://mobiles.forumpro.fr
Posté le 26-08-2005 à 12:24:14  profilanswer
 

ouais mais getElementsByTagName j'ai essayé c + chaud a faire fonctionner.
j'ai 2 div dans ma page.
 
qd j'lui fait:
 
var objet = document.getElementsByTagName("div" );
alert(objet.length);
 
il m'affiche 1
why ?!?

n°1185135
masklinn
í dag viðrar vel til loftárása
Posté le 26-08-2005 à 12:27:10  profilanswer
 

parce qu'il a trouvé un seul div dans la page [:spamafote]


---------------
I mean, true, a cancer will probably destroy its host organism. But what about the cells whose mutations allow them to think outside the box by throwing away the limits imposed by overbearing genetic regulations? Isn't that a good thing?
n°1185145
zizou771
http://mobiles.forumpro.fr
Posté le 26-08-2005 à 12:32:44  profilanswer
 

non ok je sais comment faire:
 
var mesDiv = document.getElementsByTagName("div" );
 
for(i in mesDiv){
mesDiv[i].style.visibility="hidden";
}

n°1185147
zizou771
http://mobiles.forumpro.fr
Posté le 26-08-2005 à 12:33:32  profilanswer
 

mais mesDiv[0] fonctionne
mais mesDiv[1] fonctionne
mais mesDiv[i] fonctionne pas ???!!!!????

n°1185153
masklinn
í dag viðrar vel til loftárása
Posté le 26-08-2005 à 12:37:14  profilanswer
 

document.getElementsByTagName retourne une nodeList, la nodeList n'a pas d'itérateur défini dessus, faudrait apprendre à coder en javascript ptet [:pingouino]


---------------
I mean, true, a cancer will probably destroy its host organism. But what about the cells whose mutations allow them to think outside the box by throwing away the limits imposed by overbearing genetic regulations? Isn't that a good thing?
n°1185162
zizou771
http://mobiles.forumpro.fr
Posté le 26-08-2005 à 12:43:17  profilanswer
 

et ben si ca fonctionne comme ca desolé :)
faut juste faire
 
i=mesDiv.length-1;
while(i >= 0 ){
mesDiv[i].style.visibility="hidden";
 
ca marche nikel !!

mood
Publicité
Posté le 26-08-2005 à 12:43:17  profilanswer
 

n°1185167
masklinn
í dag viðrar vel til loftárása
Posté le 26-08-2005 à 12:45:32  profilanswer
 

pourquoi tu fais pas tout simplement

for(var i=0; i<mesDiv.length; ++i) {
    mesDiv[i].style.visibility="hidden";
}


---------------
I mean, true, a cancer will probably destroy its host organism. But what about the cells whose mutations allow them to think outside the box by throwing away the limits imposed by overbearing genetic regulations? Isn't that a good thing?
n°1185176
zizou771
http://mobiles.forumpro.fr
Posté le 26-08-2005 à 12:58:53  profilanswer
 

ouais c mieux :)

n°1185181
masklinn
í dag viðrar vel til loftárása
Posté le 26-08-2005 à 13:04:04  profilanswer
 

Et si t'es finaud, tu fais même

for(var i=mesDiv.length-1; i>=0; --i) {
    mesDiv[i].style.visibility="hidden";
}


parce que ça va entre 10 et 50% plus vite en fonction du navigateur (~10% sous MSIE, ~50% sous Firefox), et que sur des itérations sur plusieurs centaines ou milliers d'éléments ça se sent


Message édité par masklinn le 26-08-2005 à 13:04:32

---------------
I mean, true, a cancer will probably destroy its host organism. But what about the cells whose mutations allow them to think outside the box by throwing away the limits imposed by overbearing genetic regulations? Isn't that a good thing?

Aller à :
Ajouter une réponse
  FORUM HardWare.fr
  Programmation
  HTML/CSS

  getElementById

 

Sujets relatifs
Probleme dácces a des id avec des [ ] et getElementById[RESOLU]document.getElementById().innerHTML = <table>
[Javascript]remplacer document.all par document.getElementbyIDdocument.getElementById et firefox
[IE] - Problème avec getElementById()parent.document.toto vs parent.document.getElementById("toto")
document.getElementById("form2").elements[champ] has no properties[JS] FireFox plante sur mon getElementById('xxx').innerT ext.split('.')
[HTML/JS] getElementById et Textarea[HTML / JS] getelementbyid aidez moi !!!
Plus de sujets relatifs à : getElementById


Copyright © 1997-2025 Groupe LDLC (Signaler un contenu illicite / Données personnelles)