Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> Odkrywanie <tr> poprzez class
Mateostin
post
Post #1





Grupa: Zarejestrowani
Postów: 68
Pomógł: 0
Dołączył: 23.03.2016

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


Witam,

Mam napisany taki kodzik

  1. function showComments($counterComments) {
  2. var x = document.getElementsByClassName($counterComments)[0];
  3. if (x.style.display === "none") {
  4. x.style.display = "";
  5. } else {
  6. x.style.display = "none";
  7. }
  8. }


Nie potrafie przerobić tego tak aby skrypt chował i odkrywał wszystkie tr ktore są w petli, w tym przypadku działa tylko dla pierwszego wygenerowanego tr,
czy jest na to jakas rada?
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
Mateostin
post
Post #2





Grupa: Zarejestrowani
Postów: 68
Pomógł: 0
Dołączył: 23.03.2016

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


Ehhhhh, napisałem posta i nagle dostałem oswiecenia (IMG:style_emoticons/default/smile.gif)

zrobiłem tak, ze zliczylem sobie elementy tr i w petli odwoluje do tablicy:

  1. function showComments($counterComments, $countElement) {
  2. for (i = 0; i < $countElement; i++) {
  3.  
  4. var x = document.getElementsByClassName($counterComments)[i];
  5. if (x.style.display === "none") {
  6. x.style.display = "";
  7. } else {
  8. x.style.display = "none";
  9. }}
  10. }


takze to rozwiazanie mi działa, Pozdrawiam i dziekuje za błyskawiczną odpowiedź (IMG:style_emoticons/default/exclamation.gif) !
Go to the top of the page
+Quote Post

Posty w temacie


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

 



RSS Aktualny czas: 16.10.2025 - 02:48