Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> problem z funkcją onlick
patrykt
post
Post #1





Grupa: Zarejestrowani
Postów: 101
Pomógł: 0
Dołączył: 3.12.2005

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


witam, jak dostać się do interesującego mnie elementu?

  1. var mN = document.getElementById('mainNav');
  2. var mNa = mN.getElementsByTagName('a');
  3.  
  4. for(i=0; i<mNa.length; i++) {
  5. mNa[i].onclick = function() {alert(this)}
  6. }


chodzi o to this, które nie działa.
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
lopik
post
Post #2





Grupa: Zarejestrowani
Postów: 340
Pomógł: 0
Dołączył: 7.07.2006

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


Nie ma czegoś takiego, jak atrybut "value" dla elementów <a...>

A JS można jeszcze skrócić:

  1. var mN = document.getElementById('ide').getElementsByTagName('a');
  2.  
  3. for(i = 0; i < mN.length; i++)
  4. mN[i].onclick = function() { alert( this.name ) }
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: 3.10.2025 - 05:20