+ 1

Please solve my problem

My setInterval is not working can you solve it ? https://code.sololearn.com/Wy77m9R4KT6P/?ref=app

22nd Aug 2020, 3:11 PM
SUJOY DEVNATH
SUJOY DEVNATH - avatar
3 ответов
+ 2
Your code appears to work when I test it. I would clean it up to something like this though: var j = 0; function fun() { var i = setInterval(function() { j = j + 1; var target = document.getElementById("start"); target.style.width = j + "px"; }, 100); } Some areas to improve are: - remove one of your fun functions. The first definition is completely replaced by the second one. - I would reduce the interval from 500ms to something that looks smoother just because it looks smoother. - Add cursor: pointer; to your #start CSS to make the div look like something more important happens when you click it.
22nd Aug 2020, 3:39 PM
Josh Greig
Josh Greig - avatar
+ 1
It's working.. Check again.. But why you write 2 function for fun? Remove one....
22nd Aug 2020, 3:36 PM
Jayakrishna 🇮🇳
+ 1
Thanks to everyone who tried to help me. Actually it has been solved in the comment. Now It is running. In the two functions, one in wrong and one is correct. Josh Greig and Jayakrishna🇮🇳 thanks
22nd Aug 2020, 7:05 PM
SUJOY DEVNATH
SUJOY DEVNATH - avatar