JavaScirpt Tutorial Index

JavaScript Tutorial Javascript Example Javascript comment Javascript Variable Javascript Data Types Javascript Operators Javascript If Else Javascript Switch Statement Javascript loop JavaScript Function Javascript Object JavaScript Arrays Javascript String Javascript Date Javascript Math Javascript Number Javascript Dialog Box Javascript Window Object Javascript Document Object Javascript Event Javascript Cookies Javascript getElementByID Javascript Forms Validation Javascript Email Validation Javascript Password Validation Javascript Re-Password Validation Javascript Page Redirect Javascript Print How to Print a Page Using JavaScript Textbox events in JavaScript How to find the largest number contained in a JavaScript Array?

Misc

JavaScript P5.js JavaScript Minify JavaScript redirect URL with parameters Javascript Redirect Button JavaScript Ternary Operator JavaScript radio button checked value JavaScript moment date difference Javascript input maxlength JavaScript focus on input Javascript Find Object In Array JavaScript dropdown onchange JavaScript Console log Multiple variables JavaScript Time Picker Demo JavaScript Image resize before upload Functional Programming in JavaScript JavaScript SetTimeout() JavaScript SetInterval() Callback and Callback Hell in JavaScript Array to String in JavaScript Synchronous and Asynchronous in JavaScript Compare two Arrays in JavaScript Encapsulation in JavaScript File Type Validation while Uploading Using JavaScript or jquery Convert ASCII Code to Character in JavaScript Count Character in string in JavaScript Get First Element of Array in JavaScript How to convert array to set in JavaScript How to get current date and time in JavaScript How to Remove Special Characters from a String in JavaScript Number Validation in JavaScript Remove Substring from String in JavaScript

Interview Questions

JavaScript Interview Questions

Javascript Document Object

JavaScript Document Object

Document object represents the whole HTML documents. When HTML document is loaded in browser it becomes the document object. It is the root elements that represent the HTML documents. With the help of document object, we can add dynamic content to our web page. The objects are organized in a hierarchy. The hierarchical structure applies to the organization of objects in a web document. Window object- Window object is the top of the hierarchy. It is the outmost element of the object hierarchy. Document object- Each HTML document that gets loaded into a window becomes a document object. The document contains the contents of the page. Form object- Everything insert in the <form>?</form> tags sets the form object. Form control elements- It contains all the elements defined for that object such as text fields, buttons, radio buttons, and checkboxes.

Example

<!DOCTYPE html>  
<html>  
<body>  
<script type="text/javascript">  
function printvalue(){    
var name=document.form1.name.value;    
alert("Welcome: "+name);    
}    
</script>  
<form name="form1">  
Name:<input type="text" name="name"/>  
<input type="button" onclick="printvalue()" value="Print Name"/>  
</form>  
</body>  
</html>
Try Now