What will be the output of the following JavaScript code? [code] <button onclick="myFunction()">Try it</button> <p id="demo">one</p> <script> fu

Thành Nguyễn

New member
What will be the output of the following JavaScript code?
Code:
<button onclick="myFunction()">Try it</button>
<p id="demo">one</p>
<script>
function myFunction() 
{
   var str = document.getElementById("demo").innerHTML; 
   var txt = str.replace("one","two");
   document.getElementById("demo").innerHTML = txt;
}
</script>
A. one
B. two
C. error
D. undefined
 

Tìm kiếm

Back
Top