Metoda jQuery Misc every () .

❮ Různé metody jQuery

Příklad

Upozorněte na text každého prvku <li>:

$("button").click(function(){
  $("li").each(function(){
    alert($(this).text())
  });
});

Definice a použití

Metoda every() určuje funkci, která se má spustit pro každý odpovídající prvek.

Tip: return false lze použít k předčasnému zastavení smyčky.


Syntax

$(selector).each(function(index,element))

Parameter Description
function(index,element) Required. A function to run for each matched element.
  • index - The index position of the selector
  • element - The current element (the "this" selector can also be used)

❮ Různé metody jQuery