Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8140741
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T12:15:56+00:00 2026-06-06T12:15:56+00:00

Its hard to explain this so I’ll try my best. Is it possible to

  • 0

Its hard to explain this so I’ll try my best.

Is it possible to use .remove() to remove a javascript function from being repeated?

function

function readytouseCard() {
    console.log(this);
    $('.cardCVV input[name=cvv1]').keyup(function () {
        console.log("s");
        var checkCVV = $('.cardCVV input[name=cvv1]').filter(function () {
            return $.trim(this.value).length < 3;
        }).length === 0;
        if (checkCVV) {
            $("li.checkCode").addClass("checked");
        } else {
            $("li.checkCode").removeClass("checked");
        }
        checklistCheck();
    });

    function checklistCheck() {
        var counting = $("li.checked:not(.title)").length;
        if (counting == 6) {
            console.log(counting);
            $("input[name=purchase]").attr("disabled", false);
            $("input[name=purchase]").removeClass("purchase-btn-disabled");
            $("input[name=purchase]").addClass("purchase-btn");

        } else {
            $("input[name=purchase]").attr("disabled", true);
            $("input[name=purchase]").removeClass("purchase-btn");
            $("input[name=purchase]").addClass("purchase-btn-disabled");
        }
    }
}

The Main

$("li#usercurrentcc").click(function (e) {
    e.preventDefault();
    var selectedID = $(this).attr("data-id");
    var qString = 'selectedID=' + selectedID;
    $.post('/assets/inc/get-logged-info-card.php', qString, function (results) {
        if ($("#usercurrentccbox, #addnewccbox").length != 0) {
            $("#usercurrentccbox, #addnewccbox").fadeOut("fast", function () {
                $(this).remove();
                $("<div class='creditCardDetails' id='usercurrentccbox'><div class='creditCard'><div class='cardChoice'><span>Choose Card Type</span><input name='cctype1' type='radio' value='V' class='lft-field' id='visa' /><label for='visa'></label><input name='cctype1' type='radio' value='M' class='lft-field' id='mastercard' /><label for='mastercard'></label><input name='cctype1' type='radio' value='A' class='lft-field' id='amex' /><label for='amex'></label></div><!--cardChoice--><div class='cardNumber'><input name='ccn1' id='ccn' type='text' class='long-field' value='" + results[0].maskccn + "' maxlength='19' readonly /></div><div class='cardCVV'><input name='cvv1' id='cvv' type='text' maxlength='5' class='small-field' /></div><div class='creditCardName'><input name='ccname1' id='ccname' type='text' class='long-field' value='" + results[0].ccname + "' readonly/></div><div class='cardDate'><input name='exp11' id='exp1' type='text' maxlength='2' class='small-field' value='" + results[0].ccm + "' readonly /><input name='exp21' id='exp2' type='text' maxlength='4' class='small-field' value='" + results[0].ccy + "' readonly /></div></div><!--creditCard-->").insertAfter("#paymentCardChoice");
                $('#usercurrentccbox .cardChoice input#' + results[0].cct + '').attr("checked", true);
                $('#usercurrentccbox .cardChoice label').removeClass("active");
                $('#usercurrentccbox .cardChoice label[for="' + results[0].cct + '"]').addClass("active");
                $("li:not(.title,.checkCode)").addClass("checked");
            });
            readytouseCard();
        } else {
            $(".submit-btn").fadeIn();
            $("<div class='creditCardDetails' id='usercurrentccbox'><div class='creditCard'><div class='cardChoice'><span>Choose Card Type</span><input name='cctype1' type='radio' value='V' class='lft-field' id='visa' /><label for='visa'></label><input name='cctype1' type='radio' value='M' class='lft-field' id='mastercard' /><label for='mastercard'></label><input name='cctype1' type='radio' value='A' class='lft-field' id='amex' /><label for='amex'></label></div><!--cardChoice--><div class='cardNumber'><input name='ccn1' id='ccn' type='text' class='long-field' value='" + results[0].maskccn + "' maxlength='19' readonly /></div><div class='cardCVV'><input name='cvv1' id='cvv' type='text' maxlength='5' class='small-field' /></div><div class='creditCardName'><input name='ccname1' id='ccname' type='text' class='long-field' value='" + results[0].ccname + "' readonly/></div><div class='cardDate'><input name='exp11' id='exp1' type='text' maxlength='2' class='small-field' value='" + results[0].ccm + "' readonly /><input name='exp21' id='exp2' type='text' maxlength='4' class='small-field' value='" + results[0].ccy + "' readonly /></div></div><!--creditCard-->").insertAfter("#paymentCardChoice");
            $('#usercurrentccbox .cardChoice input#' + results[0].cct + '').attr("checked", true);
            $('#usercurrentccbox .cardChoice label').removeClass("active");
            $('#usercurrentccbox .cardChoice label[for="' + results[0].cct + '"]').addClass("active");
            $("li:not(.title,.checkCode)").addClass("checked");
        }
        readytouseCard();
    }, "json");
});
readytouseCard();

The function starts and works on the first click but after that it doesn’t work again. console log just shows Window # and when I click again it show Window # Window #

So I was hoping there was a way to kill the function readytouseCard() using .remove();

Thanks in advance

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T12:15:58+00:00Added an answer on June 6, 2026 at 12:15 pm

    You can’t “remove” functions, you can just override them, e.g. readytouseCards = function(){}.

    However I don’t understand, why you want to to that. And Console logging Window is correct, because you have console.log(this); on the first line of your function. Since you call readytouseCards from global context, this is bound to window.

    Your actual problem is that you attach an eventhandler inside your readytouseCards(). Thus calling the function the second time attaches the eventhandler twice. This results in checklistCheck() being called twice on every keyup. This is indicated by your console logging window twice.

    You need to refactor your whole code:

    Attach the eventhandler ONCE in the beginning via .on() (jQuery on()) so that elements added to the dom later on have the eventhandler attached too.

    $(document).on('keyup', '.cardCVV input[name=cvv1]', function () { ... }
    

    and kill the function readytouseCard() by moving the checklistCheck() out of it. Finally, omit the readytouseCard(); calls.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

inHi, this question is fast, but from my point of view its pretty hard.
Uhh Sorry its really hard to explain but. This is already a string: login_username=Username&login_password=Password&login_submit=Submit
its hard for me to explain this one, but i hope some code will
Question is kind of hard to ask. I'll try my best to explain it.
This is a really tricky question to ask as its very hard to explain
This is a bit hard to explain, so I'll try with an example. Let's
It's hard to put this into the title, so let me explain. I have
sorry for the confusing title, its really hard for me to explain what i
It's quite hard to explain what I'm trying to do, I'll try: Imagine a
I heard its hard but - possible. I simply want to do it cauz

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.