I looked over stackoverflow and other websites, but could not find the answer I am looking for.
I have a button of sorts, and I want users to ONLY be able to click on it once. This is my javascript/jquery triggering the click event. But how can I force it so that it can ONLY be clicked once?
$(document).ready(function () {
//var $new_total = $('#gtotal').val();
$('#a_is_valid').click(function () {
if ($('#code_promo').val() == 'theCode') {
$('#gtotal').val($('#gtotal').val() - ($('#gtotal').val() - (($('#gtotal').val() * .75))));
}
})
})
Use jQuery's .one()
function.
$('#a_is_valid').one('click', function(){
if ($('#code_promo').val() == 'theCode')
{$('#gtotal').val($('#gtotal').val()-($('#gtotal').val()-(($('#gtotal').val()*.75))));
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With