What will be the output of the following JavaScript code? [code] function showcommentform() { var data=”new text” document.getEleme

Trang Mắm

New member
What will be the output of the following JavaScript code?
Code:
function showcommentform() 
{  
    var data=”new text”  
    document.getElementById('mylocation').innerHTML=data;  
}  
<form name="myForm">  
<input type="button" value="comment" onclick="showcommentform()">  
<div id="mylocation"></div> 
</form>
A. Comment
B. new text
C. Error
D. Undefined
 
Answer: a
Explanation: The innerHTML property can be used to write the dynamic html on the html document. It is used mostly in the web pages to generate dynamic html such as registration form, comment form, links etc.
 

Tìm kiếm

Back
Top