Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [JavaScript][HTML]Pobieranie href dla <a>
-Gość-
post
Post #1





Goście







  1. <a class="klasa" href="link">costam</a>


jak javascriptem pobrać link kryjący się pod href ?
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi (1 - 3)
matino
post
Post #2





Grupa: Zarejestrowani
Postów: 175
Pomógł: 30
Dołączył: 9.08.2007

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


  1. var links = document.getElementsByTagName('a');
  2. for (var i = 0; i < links.length; i++)
  3. {
  4. if (links[i].href == 'link')
  5. {
  6. // Twój kod tutaj
  7. }
  8. }
Go to the top of the page
+Quote Post
BlackWorth
post
Post #3





Grupa: Zarejestrowani
Postów: 13
Pomógł: 1
Dołączył: 9.05.2011

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


var element=getDocumentByTagName("a");
var link=element.attr("href");
W JQuery tak by to wyglądało ale w js nie wiem haha.gif
Go to the top of the page
+Quote Post
mat-bi
post
Post #4





Grupa: Zarejestrowani
Postów: 690
Pomógł: 92
Dołączył: 6.02.2011

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


@up, w Jquery raczej

[JAVASCRIPT] pobierz, plaintext
  1.  
  2. $("a").each(function()
  3. {
  4. if($(this).attr('href') == "cos")
  5. //kod
  6. });
[JAVASCRIPT] pobierz, plaintext

Go to the top of the page
+Quote Post

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 Aktualny czas: 21.08.2025 - 18:01