$.each()

//var IsCodeValid;

            $('#search').mousedown(function () {
                $('div.show').hide();
            });

            $('#search').mouseup(function () {
                $('span.code').each(function () {
                    if ($(this).text() === $('#inputcode').val()) {
                        //IsCodeValid = true;
                        $(this).parents('div.show').show();
                        return false;
                    }
                    else {
                        //alert($(this).text());
                        //alert($('#inputcode').val());
                        alert('兑换码不存在');
                        $('div.show').show();
                        return false;
                        //IsCodeValid = false;
                        //$('div.show').show();
                    }
                });

                //if (IsCodeValid === false) {
                //    alert('兑换码不存在');
                //    $('div.show').show();
                //}

这个return false;相当于break

posted @ 2018-07-17 17:43  Jayesslee  阅读(121)  评论(0编辑  收藏  举报