Joke Collection Website - Cold jokes - How to solve the bug that clicking the button once and then pressing enter in js will also trigger the button event?
How to solve the bug that clicking the button once and then pressing enter in js will also trigger the button event?
The reason why pressing Enter will be created again is because when you click the button, you also get the focus on the button, if you just want to press Enter uneasily. Then use the blur () event to lose focus, or put focus () on another button.
If you only want to execute it once, you can add a public variable as a lock. When the variable is true, the function can be executed. Set the variable to false when the function is executed once. So it won't be executed twice.
var? mylock=? ture
Function? myclickfun(){
if(my lock = = true){
My Locke? =? Fake;
//Write the code needed to create the div here.
}
}
- Previous article:What does the duck in July and a half mean?
- Next article:The funniest interview with CBA All-Stars, why did UAE block Zhao Jiwei?
- Related articles
- Funny sentences for making friends
- Why can't people wear daily clothes when they are dead?
- If one day you don’t know how many drinks I’ve had, please tell me what song it is. Thank you!
- Make up a story about Nangong Wentian and Dongfang Tiexin
- Butterfly 302 Double Happiness 4002 Marin 8006 Which is better? Just getting started, let's give some other suggestions ~ ~ thank you.
- The cutest person, Vivian imitates.
- Customer service jobs require good emotional management skills. How can candidates give examples?
- Begging for a hilarious joke
- Where is the mouth of the donkey bowl?
- How to tonify kidney and strengthen yang