JavaScript innerHTML property

The JavaScript innerHTML property is used to generate the dynamic HTML and is the easiest way to modify the content of an HTML element. The dynamic HTML can be a registration form, comment form, links, etc. Syntax 1: To change the content of an HTML element document.getElementById(id).innerHTML = new HTML Syntax 2: To get the … Read more

javascript getElementsByTagName

getElementsByTagName The document.getElementsByTagName(name) is a method of the document object that is used to get an element by its tag name. Syntax: document.getElementsByTagName(name) Example: <!DOCTYPE html> <html> <body> <h1>”Get Element by Tag Name!”</h1> <p>Example</p> <p id=”DOM”></p> <script> var x = document.getElementsByTagName(“h1”); document.getElementById(“DOM”).innerHTML = ‘The text in h1 is: ‘ + x[0].innerHTML; </script> </body> </html>

javascript getElementsByName

getElementsByName The document.getElementsByName(name) is a method of the document object that is used to get an element by its name. Syntax: document.getElementsByName(name) Example: <!DOCTYPE html> <html> <body> <script type=”text/javascript”> function fruitname() { var allfruits =document.getElementsByName(“fruit”); alert(“Total Fruits:”+allfruits.length); } </script> <form> BANANA:<input type=”radio” name=”fruit” value=”BANANA”> APPLE:<input type=”radio” name=”fruit” value=”APPLE”> MANGO:<input type=”radio” name=”fruit” value=”MANGO”> STRAWBERRY:<input type=”radio” name=”fruit” … Read more

javascript getElementById

getElementById The document.getElementById(id) is a method of the document object that is used to get an element by its element id. It is the easiest way to find an HTML element in the DOM. Syntax: document.getElementById(id) Example: <!DOCTYPE html> <html> <body> <h1 id=”DOM1″>”Get Element by ID!”</h1> <p id=”DOM2″></p> <script> var myElement = document.getElementById(“DOM1”); document.getElementById(“DOM2”).innerHTML = … Read more

javascript Document object

Document object The javascript document object is the window property that is used to represent a web page or an HTML document. It is a property of the window object and thus can be written as window.document or only document.  Methods of Document Object: METHOD USES document.getElementById(id) To get an element by its element id. … Read more

Javascript Navigator object

Navigator object Window is not an object of javascript; but all the JavaScript objects, functions, and variables are a property of the window object. There are various other objects of javascript that are considered as a property of the window. The javascript navigator object is the window property which is used for browser detection and … Read more