Changing a content in a element is a good one when it comes to creating a dynamic and it is best achieved with .

to change the content of html-element-content-using-javascript/">html elements such as paragraph tag/">tag, italics tag/">tag, span tag/">tag and so on see the below example:


Question: How is you?

click the answer button and see changes


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" ""> <html xmlns=""> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title></title> <script> function myFunction() {    document.getElementById("change").innerHTML = "<b>Answer:</b> Am fine.";    document.getElementById("btn").innerHTML = "Answered"; } </script> </head>  <body> <p id="change"><b>Question:</b> How is you?</p> <button type="button" id="btn" onclick="myFunction()">Answer</button> </body> </html> 


Javascript is a language that is of the high level language that can easily be used to change the content of html on click event.



Please enter your comment!
Please enter your name here