「jQuery入門」return falseでeachループ処理を抜けるサンプル

2020年11月13日

構文
if(条件) {
return false;
}
サンプルコード

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
const cftJson = {
101:"devlop",
102:"design",
103:"AA",
104:"BB"
}
$.each(cftJson,function(m,n) {
if(n==="AA"){
return false;
}
console.log( m + ": " + n);
});
const cftJson = { 101:"devlop", 102:"design", 103:"AA", 104:"BB" } $.each(cftJson,function(m,n) { if(n==="AA"){ return false; } console.log( m + ": " + n); });
const cftJson = {
      101:"devlop",
      102:"design",
      103:"AA",
      104:"BB"
}

$.each(cftJson,function(m,n) {
      if(n==="AA"){
            return false;
      }
      console.log( m + ": " + n); 
});

結果
101: devlop
102: design

jQuery

Posted by arkgame