Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> Jak w juery za pomocą linków dynamicznie zmienić zawartość value w input?
marcus755
post
Post #1





Grupa: Zarejestrowani
Postów: 158
Pomógł: 1
Dołączył: 6.12.2012

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


Hej wszystkim:-)

Jak zrobić w jquery?
żeby gdy klikamy link o id="test1" - value zmienia się o +1,
a gdy klikamy link o id="test0", to zmniejsza się o -1, a gdy mamy w value=0 (to nie zmniejsza mniej niż 0)

Poniżej skrypt, który napisałem, ale nie działa...

  1.  
  2. <a href="#" id="test0"></a>
  3. <label>Ilość</label>
  4. <input name="0" type="text" value="0" id="test11">
  5. <a href="#" id="test1"></a>
  6.  
  7. var n = 0;
  8. $("#test1").click(function (e) {
  9. e.preventDefault(); // prevent the default action
  10. e.stopPropagation; // stop the click from bubbling
  11. var text = $(this).text();
  12. $("input").find("test11").val(++n);
  13. });
  14.  
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 - 01:44