0

Please Help me. The code is not working.

I want that the function named "two()" executes in the <p> element.But the css styles is not applied after execution . https://code.sololearn.com/W1s95zCj1fGX/#js

26th Feb 2020, 12:42 PM
Sabyasachi Pramanik
Sabyasachi Pramanik - avatar
2 Respostas
+ 2
You use `document.write` inside function `two`. The document content is erased as you call `document.write`, there will only be the output of `document write` by then. You can `return x + y;` from function `two` instead. This will not erase document content, and element style, obviously. The call to `setTimeout` is missing the second argument, which defines the wait time (in milliseconds) before function `one` is invoked. Please check if that was really what you meant to do 👍 (Edited)
26th Feb 2020, 12:49 PM
Ipang
+ 2
Wait for 2 seconds and the code will be invoked function one(){ var one=document.getElementById('one'); one.style.backgroundColor='red'; function two(x,y){ return x+y; } one.innerHTML=two(15,20); } setTimeout(one,2000)
26th Feb 2020, 1:53 PM
JS LOVER
JS LOVER - avatar