qq_遁去的一_1
2019-03-15 18:14:39
$scope.add = function(){ $(".showdetailsadd input").each(function () { console.log( $(this).parent().find(".colr").length == 1 && $(this).val() == "" ) if ($(this).parent().find(".colr").length < 1 && $(this).val() == "") { nonull = $(this).siblings().find("span").eq(0).text(); console.log(nonull); return false; } }) if (nonull) { console.log(nonull); $scope.XHRmessage_show = nonull + "輸入有誤或未輸入"; $scope.message_show_f = true; $timeout(function () { $scope.message_show_f = false; }, 2000) return false; }}為什么進到if ($(this).parent().find(".colr").length < 1 && $(this).val() == "")條件中,已經(jīng)return了,還是會進到if(nonull)條件中,望大佬指導
5 回答

拉莫斯之舞
TA貢獻1820條經(jīng)驗 獲得超10個贊
在jquery的each()
里用return false;
== 正常for
用break;
break;
只是跳出循環(huán),不會結(jié)束方法

慕碼人2483693
TA貢獻1860條經(jīng)驗 獲得超9個贊
兄弟一個函數(shù)里面的return只能結(jié)束當前函數(shù)在這里就是
function () {
console.log( $(this).parent().find(".colr").length == 1 && $(this).val() == "" )
if ($(this).parent().find(".colr").length < 1 && $(this).val() == "") {
nonull = $(this).siblings().find("span").eq(0).text();
console.log(nonull);
return false;
}
}
建議看下JS的書。JS這門語言了解不夠。

慕森卡
TA貢獻1806條經(jīng)驗 獲得超8個贊
添加回答
舉報
0/150
提交
取消