JavaScript Can Change HTML Content
One of many HTML methods is getElementById().
This example uses the method to "find" an HTML element (with id="demo"), and changes the element content (innerHTML) to "JavaScript"
<!DOCTYPE html>
<html>
<body>
<h1> JavaScript change the content</h1>
<p id="demo">JavaScript can change the HTML content.</p>
<button type="button"
onclick="document.getElementById('demo').innerHTML = 'JavaScript!'">
Click Me!</button>
</body>
</html>
Result :
1. before click
JavaScript change the content
JavaScript can change HTML content.
2. After click
JavaScript change the content
JavaScript!
0 comments:
Post a Comment
Thanks For Coming The Page.