Latest web development tutorials

Miscellaneous jQuery each () method

jQuery Misc Methods jQuery Misc Methods

Examples

Output text of each <li> element:

$ ( "Button"). Click (function () {$ ( "li"). Each (function () { alert ($ (this). text ()) });});

try it"

Definition and Usage

each () method as a function of each matching element specified to run.

NOTE: Returns false can be used as soon as possible to stop the cycle.


grammar

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

参数 描述
function(index,element) 必需。为每个匹配元素规定运行的函数。
  • index- 选择器的 index 位置。
  • element- 当前的元素(也可使用 "this" 选择器)。


jQuery Misc Methods jQuery Misc Methods