Important Notice:

Course Content
Switch Statement
0/1
break and continue Statements
0/3
Basic Form Validation in JavaScript
0/1
JavaScript & Angular JS (Chapter- 6) M2-R5.1
About Lesson

innerHTML:-

                    document.getElementById(id) method का use HTML Elements में define की गयी ID के according element को select कर सकते हैं। इस method के through element select करने पर single element Object मिलता है , क्योंकि ID किसी भी element पर unique ही होती है, same ID को आप एक से ज्यादा elements पर नहीं लगा सकते हैं अगर document में Element present है तो इसका Object मिलता है, otherwise null .

syntax:- document.getElementById(id)

 

innerHTML:-

                    Using document.getElementById(id) method, you can select the element according to the ID defined in HTML Elements. By selecting an element through this method, a single element object is obtained, because ID is unique on any element, you cannot use the same ID on more than one element. If the element is present in the document, then its object is obtained. otherwise null.

syntax:- document.getElementById(id)

Example:

innerHTML Example

<!DOCTYPE html>

<html>

<body>

<h1>innerHTML</h1>

<p>how to display output in javascript</p>

<p id=”one”></p>

<script>

document.getElementById(“one”).innerHTML = 3+2;

</script>

</body>

</html>

error: Content is protected !!