Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Web Technology by (6.1k points)
recategorized by
Could you please let me know the use of innerHTML in Javascript?

1 Answer

0 votes
by (11.7k points)

The innerHTML is a  property that can be used to write dynamic html on the html document.

Mostly, it is used in web pages to generate dynamic html such as registration form, comments links etc.

<script type="text/javascript" >  

function displayformcomment() {  

var data="Name:<input type='text' name='name'><br>Comment:<br><textarea rows='6' cols='70'></textarea>  

<br><input type='submit' value='Post Comment'>";  

document.getElementById('mylocation').innerHTML=data;  

}  

</script>  

<form name="myForm">  

<input type="button" value="comment" onclick="displayformcomment()">  

<div id="mylocation"></div>  

</form>

If you want to become proficient in Web Development, check out the Web Development course offered by Intellipaat.

Related questions

Browse Categories

...