U
U
un1ted2202021-06-15 17:56:20
JavaScript
un1ted220, 2021-06-15 17:56:20

The input does not work on the phone, but on the computer it works, what should I do?

$(".cart-info__promo").on("keyup", (function () {
        var t;
        if (t = $(this).val(), $.ajax({
                type: "GET",
                url: "../db/promo.php",
                data: {
                        promocode: t
                },
                async: !1,
                dataType: "json",
                success: function (t) {
                        s = t
                }
        }), "true" == s.isCorect) {
                if (o.isPromo) return;
                $(".cart-info__price-price").addClass("promo-done"),
                o.promo = o.price * (1 - s.procent / 100),
                $(".cart-info__price-promo").text(`$ {
                        o.promo
                }
                $ {
                        o.currency
                }`),
                o.isPromo = !0
        } else $(".cart-info__price-price").removeClass("promo-done"),
        $(".cart-info__price-promo").text(""),
        o.isPromo = !1
}))


Unfortunately, I minimized the code and did not save the old file, but that's not the point. For some reason it does not work on mobile phones, but everything works on desktop

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Stefan, 2021-06-15
@un1ted220

keyup event doesn't work on mobile, add input:

$(".cart-info__promo").on("keyup input", (function () {
        var t;
        if (t = $(this).val(), $.ajax({
                type: "GET",
                url: "../db/promo.php",
                data: {
                        promocode: t
                },
                async: !1,
                dataType: "json",
                success: function (t) {
                        s = t
                }
        }), "true" == s.isCorect) {
                if (o.isPromo) return;
                $(".cart-info__price-price").addClass("promo-done"),
                o.promo = o.price * (1 - s.procent / 100),
                $(".cart-info__price-promo").text(`$ {
                        o.promo
                }
                $ {
                        o.currency
                }`),
                o.isPromo = !0
        } else $(".cart-info__price-price").removeClass("promo-done"),
        $(".cart-info__price-promo").text(""),
        o.isPromo = !1
}))

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question