提前返回的情況
$("button:first").click(function() { ? ? ? ?//遍歷所有的li ? ? ? ?//修改每個li內的字體顏色 ? ? ? ?$("li").each(function(index, element) { ? ? ? ? ? ?if (index <5) { ? ? ? ? ? ? ? ?$(this).css('color','red') ? ? ? ? ? ?}else ? ? ? ? ? ?return ? ? ? ?}) ? ?}) 提前返回的情況,return后隨便返回什么,false、true、1、0、其他數都是一樣的效果
2017-08-11
只有return false可以
jQuery內部是全等比較,即 返回值 === false;