This is a translated page. The original can be found here: http://iwebdevel.com/2009/06/20/javascript-how-to-get-the-index-position-within-a-group-of-an-object-with-jquery/
UPDATES VIA RSS | Email GÜNCELLEME VIA RSS | E-posta Get updates via feedburner Get updates via twitter
Home / Coding / JavaScript & Ajax / JavaScript: How to get the i… Ana Sayfa / Kodlama / JavaScript & Ajax / JavaScript: nasıl i almak için ...

JavaScript: How to get the index (position within a group) of an object with jQuery? JavaScript: jQuery ile nasıl bir nesnenin (konum bir grup içinde) kütüğü almak için?

Posted on 20. 20 tarihinde gönderildi. Jun, 2009 by Dragos in Coding , JavaScript & Ajax Haziran, 2009 Kodlama, JavaScript ve Ajax da Dragos tarafından

I've spent some time today figuring out how to obtain that index and finally I've just puzzled it out. Bugün nasıl ve kütüğü elde etmek için nihayet ben o dışarı şaşkın sonra bulmaktan biraz zaman geçirdim.

Let's say we have a group of objects all containing the class=”house”. 's Biz nesneleri bütün sınıfı içeren bir grup var diyelim = "ev". Now if we are referencing to the first element within the group and we'd like to find out it's index (well it's obvious in this case), we'd use this piece of code: Şimdi eğer ilk elemanı başvurarak grubu içinde ve biz onun endeksi (iyi bu durumda belli öğrenmek istiyorsanız), biz bu kod parçasının kullanmanız gerekmektedir:

 var indexOfFirstElement=$('.house').index($('.house:first')); //indexOfFirstElement=0; var indexOfFirstElement =$('. ev '). kütüğü ($('. evi: İlk')); / / indexOfFirstElement = 0; 

So, the code works as follows: we're searching within all elements of a group all grouped by the class=”house” ( $('.house') ). Bunun için, kodu aşağıdaki gibi çalışır: bir grup tüm class = "ev" ($ ( '. Ev') gruplandırılmış tüm unsurları içinde arıyorsanız). Now we are looking for the index if an element within this group, in our case it's the first element of the group ( $('.house') .index($('.house:first')) ). Şimdi kütüğü arıyorsanız eğer bizim durumumuzda Bu grup içinde grubun ilk elemanı ($ ( '. House''s unsuru). Kütüğü ($('. evi: İlk '))).

Here's another example to help you better understand how index() works: Daha iyi nasıl endeksi () çalıştığını anlamak için başka bir örnek:

 $('.house').each(function(i){ $ ( '. ev'). her (function (i) ( 
      if(i==3) alert($('.house').index(this)); //alerts 3, supposing there are 3 or more elements with class="house" if (i == 3) uyarı ($('. ev '). indeksi (bu)); / /, orada sınıfı ile 3 veya daha fazla eleman = "evi vardır supposing" 3 uyarılar 
 }); )); 

So basically, if you need to find out the index of an element within a group, you should first specify the group and then pass the object you need to find the index of as a parameter to the index() function. Nedenle temelde, bir grup içinde bir elemanın indeksi bulmak gerekiyor, önce ve sonra sizin kütüğü bulmak gerekir nesne geçmek grup belirtmelisiniz kütüğü bir parametre olarak () fonksiyonu.

Translate this post Translate bu yazı


Related posts: Ilgili posta:

  1. JavaScript: GIFless animation. JavaScript: GIFless animasyon. Animate images,logos with jQuery Animate görüntüler, jQuery ile logolar
  2. JavaScript: Send function as a parameter to another function (callbacks) JavaScript: başka bir işlev (geriçağırımları) bir parametre olarak işlev gönder
  3. JavaScript: What if jQuery animation doesn't fire/start? JavaScript: Ya jQuery animasyon olmayan yangın / başlar?
  4. JavaScript: Where do I Find All Properties for All HTML Elements ? JavaScript: nereden Tüm HTML Elements Tüm Emlaklar bulabilirim?
  5. Javascript: How to validate email address with JavaScript? Javascript: Nasıl JavaScript ile e-posta adresinizi doğrulamak için?

    blog comments powered by Disqus Blog Yorumlar Disqus tarafından desteklenmektedir