Why do it is showing before clicking the button | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
30th Jul 2022, 11:12 AM
Saddam Hussain
Saddam Hussain - avatar
8 Answers
30th Jul 2022, 1:36 PM
Saddam Hussain
Saddam Hussain - avatar
+ 2
Saddam Hussain Because you are calling function on setInterval(f,200) call this inside another function function fun() { setInterval(f,200) }
30th Jul 2022, 11:20 AM
A͢J
A͢J - avatar
+ 2
Ipang I want to show the timer after the button is clicked . Help me please
30th Jul 2022, 1:23 PM
Saddam Hussain
Saddam Hussain - avatar
+ 2
Saddam Hussain Just do like that as I said and change onclick event function 'f()' to 'fun()'
30th Jul 2022, 1:28 PM
A͢J
A͢J - avatar
+ 2
Saddam, I thought you meant to increment counter by clicking the button, that's why I said you didn't need the setInterval() AJ had provided you good answer in this case.
30th Jul 2022, 1:32 PM
Ipang
+ 1
You don't even need the setInterval() since you have set the button "onclick" attribute to invoke function f()
30th Jul 2022, 12:03 PM
Ipang
+ 1
A͢J will you please help me by giving the full code
30th Jul 2022, 12:07 PM
Saddam Hussain
Saddam Hussain - avatar
+ 1
ok I am trying
30th Jul 2022, 1:29 PM
Saddam Hussain
Saddam Hussain - avatar