Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> innerHTML nie działa z getElementsByClassName
AboutMe
post 9.10.2018, 19:23:36
Post #1





Grupa: Zarejestrowani
Postów: 261
Pomógł: 0
Dołączył: 24.02.2008

Ostrzeżenie: (0%)
-----


Dlaczego poniższy kod działa gdy użyje się getElementById a nie działa z getElementsByClassName -> http://jsfiddle.net/n2ofsyua/

  1. document.getElementById('id-block').innerHTML += '<div id="new-block">xxx</div>';
  2. document.getElementsByClassName('class-block').innerHTML += '<div id="new-block">xxx</div>';


OK, już mam, trzeba użyć

Cytat
document.getElementsByClassName('class-block')[0].innerHTML += '<div id="new-block">xxx</div>';


Tylko jak zrobić żeby to działało na wielu elementach o nazwie class-block?

Ten post edytował AboutMe 9.10.2018, 19:23:47
Go to the top of the page
+Quote Post

Posty w temacie


Reply to this topicStart new topic
1 Użytkowników czyta ten temat (1 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Wersja Lo-Fi Aktualny czas: 23.04.2024 - 14:53