js遍历

1 js的遍历方式

  for(初始化值;循环结束条件;步长)

2 jq的遍历方式

  1 jq对象.each(callback)

    语法:

    jquery对象.each(function(index,element){});

      index 元素在集合中的索引

      element 集合中的每一个元素

      this 集合中的每一个元素对象

    回调函数返回值

      true 如果当前 function返回为false 则结束循环(break)

      false 如果当前 function返回为ture 则结束本次循环 继续下次循环(continue)

  2 each(object,[callback])

  3 for..of jquery 3.0 版本之后提供的方式

   for(元素对象 of 容器对象)

 

 

posted @ 2023-02-20 10:59  帕拉利斯  阅读(32)  评论(0)    收藏  举报