Pomoc - Szukaj - Użytkownicy - Kalendarz
Pełna wersja: [JavaScript]Przerobienie kodu
Forum PHP.pl > Forum > Przedszkole
RaiZeN
Witam,

Proszę o przeróbkę prostego kodu javascript. Oto on:
  1. var itemName = $(this).find(".smallimg").first().attr("alt");
  2.  
  3. if (itemName in PriceList) {
  4. $(this).find(".rarity").html(PriceList[itemName]);
  5. return;
  6. }
  7. $(this).find(".rarity").html("Loading ...");
  8. var item =$(this);
  9.  
  10. storage.get("currency", function(currency) {
  11. $.getJSON("http://steamcommunity.com/market/priceoverview/?currency="+currency+"&appid="+appId+"&market_hash_name=" + itemName, function(json){
  12. var price = "Not found";
  13. if (json.success){
  14. if (typeof json.lowest_price != 'undefined')
  15. price = json.lowest_price;
  16. else if (typeof json.median_price != 'undefined')
  17. price = json.median_price;
  18. }
  19. PriceList[itemName] = price;
  20. item.find(".rarity").html(price);
  21. item.addClass("priced");
  22. }).fail(function(){
  23. item.find(".rarity").html("Not found");
  24. item.addClass("priced");
  25. });
  26. });
  27. });


Chcę aby kod nie zmieniał napisu w klasie "rarity" tylko aby dodawał klasę "priced" pod divem z klasą "item". W JS jestem noga, dlatego proszę was o pomoc. tongue.gif

// jeśli zły dział proszę o przeniesienie
robertpiaty
zmień kod w lini 21 na
  1. item.next().addClass("priced");

i wywal kod z lini 20

Podobnie zrób w lini 23 i 24
RaiZeN
Ok, znajomy już mi pomógł w inny sposób ale dzięki za chęci. tongue.gif
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.