热门关键字:
jquery > jquery教程 > jquery教程 > jquery跳出循环each并带返回值返回

jquery跳出循环each并带返回值返回

404
作者:管理员
发布时间:2021/2/8 16:39:45
评论数:0
转载请自觉注明原文:http://www.jq-school.com/Show.aspx?id=3976
jquery的循环函数是each()


结束跳出循环:return false [相当于break]


结束本次循环进入下次循环:return true [相当于continue]








//jquery跳出循环each并带返回值返回
    function MyEach(obj, text) {
        var val = "";
        //开始循环
        $("#orderstate option").each(function () {
            if ($(this).text() == text) {
                val = $(this).val();
                return false;//用false结束循环
            }
        });
        return val;
    }





如果您觉得本文的内容对您的学习有所帮助:支付鼓励



关键字:jQuery
友荐云推荐