在jquery中,each是“循环遍历一组元素”的意思;each()方法的作用就是遍历指定的对象和数组,相当于程序中的for循环,返回false可用于及早停止循环,语法为“$.each(需要遍历的对象或数组,用于循环执行的函数)”。
本教程操作环境:windows10系统、jquery3.2.1版本、Dell G3电脑。
是循环遍历所选择到的一组元素的意思,相当于程序中的for循环
jQuery.each() 函数用于遍历指定的对象和数组。
语法
$.each( object, callback )
object Object类型 指定需要遍历的对象或数组。
callback Function类型 指定的用于循环执行的函数。
each() 方法规定为每个匹配元素规定运行的函数。
提示:返回 false 可用于及早停止循环。
示例如下:
遍历数组:
123
输出结果:
遍历对象:
123
输出结果:
相关视频教程推荐:jQuery视频教程
Das obige ist der detaillierte Inhalt vonjquery中each是什么意思. Für weitere Informationen folgen Sie bitte anderen verwandten Artikeln auf der PHP chinesischen Website!