0% found this document useful (0 votes)
10 views1 page

Change HTML Content with JavaScript

This document discusses how to change the content of HTML elements using the innerHTML property. It explains that the innerHTML property can be used to modify an element's content by setting it equal to a new HTML string. An example is provided that gets an element by ID and changes its text from "Hello World!" to "New text!" using innerHTML.

Uploaded by

GxysNet
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views1 page

Change HTML Content with JavaScript

This document discusses how to change the content of HTML elements using the innerHTML property. It explains that the innerHTML property can be used to modify an element's content by setting it equal to a new HTML string. An example is provided that gets an element by ID and changes its text from "Hello World!" to "New text!" using innerHTML.

Uploaded by

GxysNet
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

HTML

Changing HTML Content


The easiest way to modify the content of an HTML element is by using the innerHTML property.
To change the content of an HTML element, use this syntax:
[Link](id).innerHTML = new HTML
This example changes the content of a <p> element:

Example
<html>
<body>
<p id="p1">Hello World!</p>
<script>
[Link]("p1").innerHTML = "New text!";
</script>
</body>
</html>
Check Prime/Not
<form nmae=frm action=purl method=get>
Check Prime or Not: <input type=text name=pno onblur=[Link]()>
</form>

You might also like