How to make a Function Run on the second onclick() without onDBLClick | Click button Two times To run the Code! - MRNIAMSTER

Advertisement

Post Top Ad

How to make a Function Run on the second onclick() without onDBLClick | Click button Two times To run the Code!

Share This

Hi guys so in this today I want to show you how to use the onclick function which we used to use to just create a button and 2 and to run the code but in this tutorial I want to show you how to use the onclick function when the button is clicked twice so when I say the button is clicked twice the user has to click the code for the button twice to run the function or to go to the following function so no images tell you how to do this ,
              if you want to use the double click function guys so you just just copy the following code and here as you can see the double function what will actually happen is the use had had to click a double click and to run the following function

With ondblcick- No time delay btw two click
function func(){
  console.log("double clicked");
}
<button ondblclick="func()">Subscribe <i id="ytb" class="fa fa-youtube-square ytb"></i></button>
but what I wanted is the user has to click 2 times not double click but 2 times a button or to run the following function so if I click on a button then it will not run to the function but if I click on the button a once again then it will run to the function .
To make a Function Run on the second onclick() without onDBLClick | Click button Two times To run the Code!


var prevClick = false;
function buttonOnClick() {
    if (prevClick) {
        window.open('https://www.youtube.com/channel/UCXE6pw29K2lHS_2fB8LeU1Q?sub_confirmation=1','_blank');
        setTimeout(aTagChange, 12000);
    } else {
        prevClick = true;
    }
}

and Secondly will say I was currently using properly ads due to which are the on page script was loading so what was actually happening was that whenever the user used to click on my button the page gets the page script gets loaded and with that also my button function also gets loaded so what I did is I created the this onclick button twice function so now what will happen is one of the main uses will click on a single button that time it will it will not run the code and it will only run the ad of the full page script but if the user clicks once again by the onclick function now the user will I get attracted to buy function code for this was the main advantage of this thank you guys I hope this may help you also if yes then do don't forget to comment below and it will and it will be really means a lot thank you guys

No comments:

Post a Comment

Post Bottom Ad