SORU
3 Temmuz 2009, Cuma


Nasıl bir JSON yapısı üzerinde yineleme mı?

Aşağıdaki JSON yapısı var:

[{ "id":"10", "class": "child-of-9" }, { "id": "11", "classd": "child-of-10" }]

Nasıl bitti jQuery veya JavaScript kullanarak tekrarlar mı?

CEVAP
3 Temmuz 2009, Cuma


JQuery dokümanlar (http://docs.jquery.com/Utilities/jQuery.each) alınan:

var arr = [ "one", "two", "three", "four", "five" ];
var obj = { one:1, two:2, three:3, four:4, five:5 };

jQuery.each(arr, function() {
  $("#"   this).text("My id is "   this   ".");
  return (this != "four"); // will stop running to skip "five"
});

jQuery.each(obj, function(i, val) {
  $("#"   i).append(document.createTextNode(" - "   val));
});

Bunu Paylaş:
  • Google+
  • E-Posta
Etiketler:

YORUMLAR

SPONSOR VİDEO

Rastgele Yazarlar

  • Jon Reed

    Jon Reed

    14 AĞUSTOS 2006
  • REK Roth Productions

    REK Roth Pro

    8 Ocak 2011
  • stokelycalm

    stokelycalm

    28 Aralık 2010