Pomoc - Szukaj - Użytkownicy - Kalendarz
Pełna wersja: jquery + ajax + zmiana href w odnośnikach
Forum PHP.pl > Forum > XML, AJAX > AJAX
morawcik89
Mam taki problem.
Wczytuję za pomocą ajaxa w jquery część pliku która wygląda tak:
Kod
<p class="el"><a href="plany/o1.html" target="plan">1a 1TI</a></p>
<p class="el"><a href="plany/o2.html" target="plan">1b 1TI</a></p>
<p class="el"><a href="plany/o3.html" target="plan">1c 1TI</a></p>
<p class="el"><a href="plany/o4.html" target="plan">1d 1TEE/H</a></p>
<p class="el"><a href="plany/o5.html" target="plan">1e 1TEK</a></p>
<p class="el"><a href="plany/o6.html" target="plan">2a 2TI</a></p>
<p class="el"><a href="plany/o7.html" target="plan">2b 2TI</a></p>
<p class="el"><a href="plany/o8.html" target="plan">2c 2TI / E</a></p>
<p class="el"><a href="plany/o9.html" target="plan">2e 2TE / H</a></p>
<p class="el"><a href="plany/o10.html" target="plan">3a 3TI</a></p>
<p class="el"><a href="plany/o11.html" target="plan">3b 3TI</a></p>
<p class="el"><a href="plany/o12.html" target="plan">3d 3TEE</a></p>
<p class="el"><a href="plany/o13.html" target="plan">3e 3TEK</a></p>
<p class="el"><a href="plany/o14.html" target="plan">4a 4TI</a></p>
<p class="el"><a href="plany/o15.html" target="plan">4b 4TI</a></p>
<p class="el"><a href="plany/o16.html" target="plan">4d 4TEE</a></p>
<p class="el"><a href="plany/o17.html" target="plan">4e 4TEK</a></p>
<p class="el"><a href="plany/o18.html" target="plan">4h 4TH</a></p>


Te dane umieszczam w #help1 .
Teraz wybieram same linki ($("#help1").children().children() ), umieszczam w #plan_cont i jest ok.
Teraz nie potrafię zmienić atrybutu href na java script:plan(stary href).
Próbowałem na różne sposoby ale ciągle dodaje mi pierwszy href.
Proszę o szybką pomoc.
bregovic
Stary, po co chcesz zmieniać href? Nie lepiej dodać onclick? Np tak:
  1. $('a').each(function() {
  2. $(this).click(function() {plan($(this).href); return false;});
  3. });

Pisane z palca, pewnie są błędy.

Edit: Nie do końca rozumiem twój problem, możesz pokazać więcej kodu?
To jest wersja lo-fi głównej zawartości. Aby zobaczyć pełną wersję z większą zawartością, obrazkami i formatowaniem proszę kliknij tutaj.
Invision Power Board © 2001-2025 Invision Power Services, Inc.