Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> [JavaScript]Pobieranie wartości z kodu html w jquery
trifek
post 29.05.2020, 10:57:59
Post #1





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

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


Witajcie,
Mam taki kod w js:
  1.  
  2. $(".promo-code-ver").click(function () {
  3. $.ajax({
  4. type: 'get',
  5. url: 'checkValidateDiscountCode',
  6. dataType: "json",
  7. data: {code: $(".promo-code-input").val()},
  8. success: function (data) {
  9. if (data.status == "error") {
  10. $(".promo-code-input").val('');
  11. alert('Podany kod jest błędny');
  12. } else {
  13. let discountValue = data.discount_value;
  14. let discountType = data.code_type;
  15. let discountName = data.name;
  16.  
  17. $('.brutto_amount').each(function(index, value) {
  18. console.log(value);
  19. });
  20.  
  21. alert('Zastosowano kod rabatowy ' + data.name);
  22. }
  23. }
  24. });
  25. });
  26.  


Działa poprawnie i zwraca mi:

  1. [Log] <p class="gross brutto_amount"> (script.js, line 18)
  2. "(123.00 zł "
  3. <span class="tax">brutto</span>
  4. ")"
  5. </p>
  6.  
  7. [Log] <p class="gross brutto_amount"> (script.js, line 18)
  8. "(246.00 zł "
  9. <span class="tax">brutto</span>
  10. ")"
  11. </p>
  12.  
  13. [Log] <p class="gross brutto_amount"> (script.js, line 18)
  14. "(369.00 zł "
  15. <span class="tax">brutto</span>
  16. ")"
  17. </p>
  18.  


W jaki sposób mogę wyciągnąć same kwoty (bez zł)?
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 Wersja Lo-Fi Aktualny czas: 19.04.2024 - 09:12