jQuery each() 方法

jQuery 教程 · 2019-03-27 23:38:28

实例

输出每个 <li> 元素的文本:

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

定义和用法

each() 方法为每个匹配元素规定要运行的函数。

提示:返回 false 可用于及早停止循环。

语法

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

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

点击查看所有 jQuery 教程 文章: https://codercto.com/courses/l/35.html

查看所有标签

Developer's Guide to Social Programming

Developer's Guide to Social Programming

Mark D. Hawker / Addison-Wesley Professional / 2010-8-25 / USD 39.99

In The Developer's Guide to Social Programming, Mark Hawker shows developers how to build applications that integrate with the major social networking sites. Unlike competitive books that focus on a s......一起来看看 《Developer's Guide to Social Programming》 这本书的介绍吧!

JSON 在线解析
JSON 在线解析

在线 JSON 格式化工具

在线进制转换器
在线进制转换器

各进制数互转换器

XML 在线格式化
XML 在线格式化

在线 XML 格式化压缩工具