how to disable or enable all onClick for images on a page

前端 未结 5 1545
不知归路
不知归路 2021-01-17 17:40

When the user clicks on an image, I want the onClicks on all other images to be disabled until my function has finished.

I currently have this code that disables the

5条回答
  •  死守一世寂寞
    2021-01-17 18:30

    Basically you're setting the elements' onclick to false and true. it's the equivalent of doing something like

    
    

    then

    
    

    What you should do is maintaining some variable that you check against to see if you can start the function or not.

    locked = false;
    function yourFunction() {
        if (locked) {
            locked = true;
            //... Do what you have to do here
            locked = false;
        };
    }
    

提交回复
热议问题