Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Disable multiple clicks JavaScript

I am trying to disable multiple clicks on element or set a delay between each click to prevent content overloading

I am thinking to do something like this:

 var clicked = false;

if(!clicked)
{
    clicked = true;

    // do all my stuff right here !!

    setTimeout(function(){

        clicked = false;
    }, 3000);
}

But it's not working. Can anyone offer any suggestions?

like image 503
lotfio Avatar asked Feb 04 '23 15:02

lotfio


1 Answers

you can disable element

$(element).prop('disabled', true);

after clicking it

like image 116
Dhaval Pankhaniya Avatar answered Feb 07 '23 12:02

Dhaval Pankhaniya