Home > Web Front-end > JS Tutorial > body text

Example sharing of simple rollback operation of each loop in jquery

小云云
Release: 2018-01-12 13:05:04
Original
1395 people have browsed it

This article mainly introduces the relevant knowledge of the simple rollback operation of each loop in jquery, which has a good reference value. Let's take a look with the editor below, I hope it can help everyone.

Without further ado, please take a look at the code:

var ispass = true;
var obj = new Object();
$.each(data,function(i,td){
  var sum=data[i].sum;
  var num=data[i].num;
  var id=data[i].num;
  if(num>sum){
       ispass=false;
       alert("数量不能大于总数量!");
     sum+=num;
      return false;
     }
     obj[id]=sum;
})
if(!ispass){
  return false;//如果执行到这里则上面的each循环的内容都不存在
}else{
  $.each(obj,function(id,sum){
  alert(id);
  alert(num);
  })
}
Copy after login

Related recommendations:

What is the difference between for and foreach loop traversal in PHP

foreach loop usage example code

JQuery jumps out of each loop example code sharing

The above is the detailed content of Example sharing of simple rollback operation of each loop in jquery. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!