MCQs Test!! VB Basic Test !! Essentials of VB !! Creating User Services !! function !! Anatomy !! GK March-2019 !! DATA TYPES IN JAVA !! Classes ,Constructor ,Methods,Inheritance !! Ecology-I !! Biology 2019 !! Gk april 2019 !! Biology (living world) !! Plant anatomy !! CELL STRUCTURES AND FUNCTION !! General biology !! Human physiology !! Data structure !! Ecology-II !! GK TEST !! Reproduction in plants !! Human reproduction !! The ABC of C !! Operating system set1 !! Operating system set2 !! Gk and current affairs !! Animal kingdom !! Number system !! Animal kingdom-II !! Gk TEST-III !! Number series !! Microorganisms !! Interview question in c !! Time and Work !! Percentage !! General history !! Average !! Cells !! Locomotion and Movement !! paging !! Bacteriology !! Page replacement policy !! Secondary memory and Disk scheduling !! Introduction of Nervous System and neurons !! Plant harmones !! Transport and Mineral Nutrition in Plants !! Neurotransmitters !! Modern Indian History !! Photosynthesis in Plants !! Modern Indian History-II !! Plant respiration !! Environment & Biodiversity !! Environment & Biodiversity - II !! Algae, Bryophytes, Pteridophytes !! Area !! Cricket !! Days of the Year (India and the World) !! Plant Pathology - I !! Indian Transport System !! Plant Pathology - II !! Aptitude !! Biology !! Botany !! C language !! Computer Science !! Core Java !! Gate !! GK !! Mysql !! Operating system !! Physics !! VB-Visual Basic !! Zoology

JavaScript Tutorial

DOM In Java Script
Previous Home Next

Javascript provide DOM ( Document Object Model ) developed by the World Wide Web Consortium. its describes how all elements in an HTML page, like input fields, images, paragraphs etc .

This specification provides a platform and language-neutral interface that allows programs and scripts to dynamically access and change the content, structure and style of a document —usually HTML or XML—by providing a structured set of objects that correspond to the document’s elements.

DOM Types :

Javascript provide's several type of DOM Object.

DOM object Definition
document Represents the root node of the DOM tree and also Returns the document object for the page .
element its Represents an instance of most structures and sub-structures in the DOM.
nodeList A nodeList is equivalent to an array, but it is an array specific to storing elements.

 

There are a number of JavaScript methods specified by the DOM which allow you to access its structure.

DOM Method Definition
getElementsByTagName(name) nodeList Returns a nodeList of any elements that have a given tag specified by name.
element getElementById() its Returns the element uniquely identified by its id identifier.
document.getElementsByName() its method returns all the element of specified name.
innerHTML This property can be used to write the dynamic html on the html document.

Example of document.getElementsByName() method :


<html>
<head>    
<script >  
    
function prasun()  
 {  
    
var all language =document.getElementsByName("language");  
    alert("Total language:"+all language.length);  
    }
  
    </script>  
    <form>  
    Hindi:<input type="radio" name="language" value="Hindi">  
    English:<input type="radio" name=
	"language" value="English">  
    Sanskrit:<input type="radio" name=
	"language" value="Sanskrit">  
     
 
<input type="button" onclick=
"prasun()" value="language">  
 </form> 
</html>
</head>  

Output :

Example of document.getElementById() :


<html>
<head>

<script >
function notEmpty(){

	var myTextField = document.getElementById('myText');
	if(myTextField.value != "")
		alert("You entered: " + myTextField.value)
	else
		alert("prasant say enter some text ")		
}
</script>
<input type='text' id='myText' />
<input type='button' onclick='notEmpty()' value='CLICK' />

</html>
</head>

Output :

Previous Home Next