SlideShare a Scribd company logo
Arulkumar V
Asst.Professor- CSE
SECE
JavaScript DOM
DOM Document Object Model
 Every web page resides inside a browser window which
can be considered as an object.
 It represents the HTML document that is
displayed in that window.
 It has various properties that refer to other objects which
allow access to and modification of document content.
 This way is accessed and modified is called
the Document Object Model, or DOM.
 Hierarchical structure to the organization of objects in a
Web document. =>
objects in a Web document.
 Window object
 Document object
 Form object
 Form control elements
Property & Description
 Body - document.body
 defaultView - document.defaultView
 documentElement -
document.documentElement8/31/2008
 getElementById( id) - document.getElementById( id)
 getElementsByName( name) -
document.getElementsByName( name)
 getElementsByTagName( tagname)-
document.getElementsByTagName( tagname)

DOMs in existence
<head>
<title> Document Title </title>
<script type="text/javascript">
<!-- function myFunc()
{
var ret = document.getElementsByTagName("title");
alert("Document Title : " + ret.text ); //gets the title of doc
var ret = document.getElementById("heading");
alert(ret.innerHTML );
} //-->
</script> </head>
<body>
<h1 id="heading">This is main title</h1>
<p>Click the following to see the result:</p>
<form id="form1" name="FirstForm">
<input type="button" value="Click Me"
onclick="myFunc();" />
<input type="button" value="Cancel">
</form>
<form d="form2" name="SecondForm">
<input type="button" value="Don't ClickMe"/>
</form>
</body>
JavaScript - The Date Object
 Date object is a datatype built into the JavaScript
 Created with the new Date( )
 new Date( )
 new Date(milliseconds)
 new Date(datestring)
 new Date(year,month,date[,
hour,minute,second,millisecond ])
JavaScript - The Date Object
<html> <head>
<title>JavaScript Date Method</title> </head>
<body>
<script type="text/javascript">
var dt = Date();
document.write("Date and Time : " + dt );
</script>
</body>
</html>
Output:
Date and Time : Tue Aug 08 2017 17:15:06 GMT+0530
(India Standard Time)
JavaScript – Domain example
<html>
<body>
<p>Click the button to display the domain name of the server that
loaded this document.</p>
<button onclick="myFunction()">Try it</button>
<p id="demo"></p>
<script>
function myFunction() {
document.getElementById("demo").innerHTML =
document.domain;
}
</script></body></html>
Click the try button to display the domain name of the server that
loaded this document.
o/p: www.google.com
JavaScript - Cookie
<html>
<body>
<p id="demo">Click the button to display the cookies associated with
this document.</p>
<button onclick="myFunction()">Try it</button>
<script>
function myFunction() {
document.getElementById("demo").innerHTML =
"Cookies associated with this document: " + document.cookie;
}
</script></body></html>
Cookies associated with this document:
__gads=ID=66b36630d70e3ac5:T=1502354049:S=ALNI_Mawf4e62DiZ3EEzs_-NPMoLpCUO2Q;
_gat=1; _ga=GA1.2.148245611.1502354051; _gid=GA1.2.144215362.1502354051
JavaScript – Count Input tag
<html><head>
<script>
function getElements() {
var x = document.getElementsByTagName("input");
document.getElementById("demo").innerHTML = x.length;
}
</script></head><body>
<input type="text" size="20"><br>
<input type="text" size="20"><br>
<input type="text" size="20"><br>
<p> <input type="button" onclick="getElements()" value="How many
input elements?“> </p>
<p id="demo">Prints here:</p>
</body> </html>
Click How many input elements? Button
o/p: 4
JavaScript – CSS Manipulation
<html>
<body>
<p id="p1">
This is a text.
This is a text.
This is a text.
</p>
<input type="button" value="Hide text"
onclick="document.getElementById('p1').style.visibility='hidden'">
<input type="button" value="Show text"
onclick="document.getElementById('p1').style.visibility='visible'">
</body> </html>
2.java script  dom
2.java script  dom

More Related Content

What's hot

Java script objects
Java script objectsJava script objects
Java script objects
AbhishekMondal42
 
Internet and Web Technology (CLASS-9) [React.js] | NIC/NIELIT Web Technology
Internet and Web Technology (CLASS-9) [React.js] | NIC/NIELIT Web TechnologyInternet and Web Technology (CLASS-9) [React.js] | NIC/NIELIT Web Technology
Internet and Web Technology (CLASS-9) [React.js] | NIC/NIELIT Web Technology
Ayes Chinmay
 
Assignment4
Assignment4Assignment4
Assignment4H K
 
Client Web
Client WebClient Web
Client Web
Markiyan Matsekh
 
22 j query1
22 j query122 j query1
22 j query1
Fajar Baskoro
 
Grails Views
Grails ViewsGrails Views
Displaying message on web page in Javascript
Displaying message on web page in JavascriptDisplaying message on web page in Javascript
Displaying message on web page in Javascript
Codewizacademy
 
Javascript and DOM
Javascript and DOMJavascript and DOM
Javascript and DOM
Brian Moschel
 
JAVA SCRIPT
JAVA SCRIPTJAVA SCRIPT
JAVA SCRIPT
Mohammed Hussein
 
Introductory css and j query
Introductory css and j queryIntroductory css and j query
Jquery for post a form
Jquery for post a formJquery for post a form
Jquery for post a form
Rakesh Kumar
 
jQuery Beginner
jQuery BeginnerjQuery Beginner
jQuery Beginner
kumar gaurav
 
Cross Platform Mobile Development
Cross Platform Mobile DevelopmentCross Platform Mobile Development
Cross Platform Mobile Development
Avner Solomon
 
Jquery presentation
Jquery presentationJquery presentation
Jquery presentation
Mevin Mohan
 
Web Development Introduction to jQuery
Web Development Introduction to jQueryWeb Development Introduction to jQuery
Web Development Introduction to jQuery
Laurence Svekis ✔
 
Flexbox - верстка без float'ов by Dmitry Radyno
Flexbox - верстка без float'ов by Dmitry RadynoFlexbox - верстка без float'ов by Dmitry Radyno
Flexbox - верстка без float'ов by Dmitry Radyno
Дмитрий Радыно
 
Going with style: Themes and apps for Magento Go
Going with style: Themes and apps for Magento GoGoing with style: Themes and apps for Magento Go
Going with style: Themes and apps for Magento Go
X.commerce
 
Java script how to
Java script how toJava script how to
Java script how to
julian vega
 

What's hot (20)

Java script objects
Java script objectsJava script objects
Java script objects
 
Internet and Web Technology (CLASS-9) [React.js] | NIC/NIELIT Web Technology
Internet and Web Technology (CLASS-9) [React.js] | NIC/NIELIT Web TechnologyInternet and Web Technology (CLASS-9) [React.js] | NIC/NIELIT Web Technology
Internet and Web Technology (CLASS-9) [React.js] | NIC/NIELIT Web Technology
 
Assignment4
Assignment4Assignment4
Assignment4
 
Client Web
Client WebClient Web
Client Web
 
22 j query1
22 j query122 j query1
22 j query1
 
Grails Views
Grails ViewsGrails Views
Grails Views
 
Displaying message on web page in Javascript
Displaying message on web page in JavascriptDisplaying message on web page in Javascript
Displaying message on web page in Javascript
 
Javascript and DOM
Javascript and DOMJavascript and DOM
Javascript and DOM
 
JAVA SCRIPT
JAVA SCRIPTJAVA SCRIPT
JAVA SCRIPT
 
Introductory css and j query
Introductory css and j queryIntroductory css and j query
Introductory css and j query
 
Jquery for post a form
Jquery for post a formJquery for post a form
Jquery for post a form
 
jQuery Beginner
jQuery BeginnerjQuery Beginner
jQuery Beginner
 
Slide curs-10
Slide curs-10Slide curs-10
Slide curs-10
 
Cross Platform Mobile Development
Cross Platform Mobile DevelopmentCross Platform Mobile Development
Cross Platform Mobile Development
 
Jquery presentation
Jquery presentationJquery presentation
Jquery presentation
 
Web Development Introduction to jQuery
Web Development Introduction to jQueryWeb Development Introduction to jQuery
Web Development Introduction to jQuery
 
handout-05b
handout-05bhandout-05b
handout-05b
 
Flexbox - верстка без float'ов by Dmitry Radyno
Flexbox - верстка без float'ов by Dmitry RadynoFlexbox - верстка без float'ов by Dmitry Radyno
Flexbox - верстка без float'ов by Dmitry Radyno
 
Going with style: Themes and apps for Magento Go
Going with style: Themes and apps for Magento GoGoing with style: Themes and apps for Magento Go
Going with style: Themes and apps for Magento Go
 
Java script how to
Java script how toJava script how to
Java script how to
 

Similar to 2.java script dom

Advanced JQuery Mobile tutorial with Phonegap
Advanced JQuery Mobile tutorial with Phonegap Advanced JQuery Mobile tutorial with Phonegap
Advanced JQuery Mobile tutorial with Phonegap
Rakesh Jha
 
Week32
Week32Week32
Week32H K
 
Web 6 | JavaScript DOM
Web 6 | JavaScript DOMWeb 6 | JavaScript DOM
Web 6 | JavaScript DOM
Mohammad Imam Hossain
 
Client-side JavaScript
Client-side JavaScriptClient-side JavaScript
Client-side JavaScript
Lilia Sfaxi
 
FYBSC IT Web Programming Unit III Document Object
FYBSC IT Web Programming Unit III  Document ObjectFYBSC IT Web Programming Unit III  Document Object
FYBSC IT Web Programming Unit III Document Object
Arti Parab Academics
 
J query
J queryJ query
jQuery
jQueryjQuery
Javascript 2
Javascript 2Javascript 2
Javascript 2
pavishkumarsingh
 
DOM and Events
DOM and EventsDOM and Events
DOM and Events
Julie Iskander
 
DOM(Document Object Model) in javascript
DOM(Document Object Model) in javascriptDOM(Document Object Model) in javascript
DOM(Document Object Model) in javascript
Rashmi Mishra
 
HTML5 New and Improved
HTML5   New and ImprovedHTML5   New and Improved
HTML5 New and Improved
Timothy Fisher
 
Introduction to Html5
Introduction to Html5Introduction to Html5
Introduction to Html5
www.netgains.org
 
Devoxx 2014-webComponents
Devoxx 2014-webComponentsDevoxx 2014-webComponents
Devoxx 2014-webComponents
Cyril Balit
 
QCon 2015 - Thinking in components: A new paradigm for Web UI
QCon 2015 - Thinking in components: A new paradigm for Web UIQCon 2015 - Thinking in components: A new paradigm for Web UI
QCon 2015 - Thinking in components: A new paradigm for Web UI
Oliver Häger
 
jQuery
jQueryjQuery
Javascript.ppt
Javascript.pptJavascript.ppt
Javascript.ppt
NoralieNicol
 

Similar to 2.java script dom (20)

Dom
DomDom
Dom
 
Dom
DomDom
Dom
 
Advanced JQuery Mobile tutorial with Phonegap
Advanced JQuery Mobile tutorial with Phonegap Advanced JQuery Mobile tutorial with Phonegap
Advanced JQuery Mobile tutorial with Phonegap
 
Week32
Week32Week32
Week32
 
Web 6 | JavaScript DOM
Web 6 | JavaScript DOMWeb 6 | JavaScript DOM
Web 6 | JavaScript DOM
 
Client-side JavaScript
Client-side JavaScriptClient-side JavaScript
Client-side JavaScript
 
FYBSC IT Web Programming Unit III Document Object
FYBSC IT Web Programming Unit III  Document ObjectFYBSC IT Web Programming Unit III  Document Object
FYBSC IT Web Programming Unit III Document Object
 
Jquery
JqueryJquery
Jquery
 
J query
J queryJ query
J query
 
Jquery 2
Jquery 2Jquery 2
Jquery 2
 
jQuery
jQueryjQuery
jQuery
 
Javascript 2
Javascript 2Javascript 2
Javascript 2
 
DOM and Events
DOM and EventsDOM and Events
DOM and Events
 
DOM(Document Object Model) in javascript
DOM(Document Object Model) in javascriptDOM(Document Object Model) in javascript
DOM(Document Object Model) in javascript
 
HTML5 New and Improved
HTML5   New and ImprovedHTML5   New and Improved
HTML5 New and Improved
 
Introduction to Html5
Introduction to Html5Introduction to Html5
Introduction to Html5
 
Devoxx 2014-webComponents
Devoxx 2014-webComponentsDevoxx 2014-webComponents
Devoxx 2014-webComponents
 
QCon 2015 - Thinking in components: A new paradigm for Web UI
QCon 2015 - Thinking in components: A new paradigm for Web UIQCon 2015 - Thinking in components: A new paradigm for Web UI
QCon 2015 - Thinking in components: A new paradigm for Web UI
 
jQuery
jQueryjQuery
jQuery
 
Javascript.ppt
Javascript.pptJavascript.ppt
Javascript.ppt
 

More from PhD Research Scholar

Ajax
AjaxAjax
Quiz servlet
Quiz servletQuiz servlet
Quiz servlet
PhD Research Scholar
 
Quiz
QuizQuiz
servlet db connectivity
servlet db connectivityservlet db connectivity
servlet db connectivity
PhD Research Scholar
 
1.java script
1.java script1.java script
1.java script
PhD Research Scholar
 
Quiz javascript
Quiz javascriptQuiz javascript
Quiz javascript
PhD Research Scholar
 
Thread&amp;multithread
Thread&amp;multithreadThread&amp;multithread
Thread&amp;multithread
PhD Research Scholar
 
String
StringString
Streams&amp;io
Streams&amp;ioStreams&amp;io
Streams&amp;io
PhD Research Scholar
 
Packages
PackagesPackages
Interface in java
Interface in javaInterface in java
Interface in java
PhD Research Scholar
 
Inner classes in java
Inner classes in javaInner classes in java
Inner classes in java
PhD Research Scholar
 
Inheritance
InheritanceInheritance
Exception handling
Exception handlingException handling
Exception handling
PhD Research Scholar
 
Applets
AppletsApplets
Abstract class
Abstract classAbstract class
Abstract class
PhD Research Scholar
 
7. tuples, set &amp; dictionary
7. tuples, set &amp; dictionary7. tuples, set &amp; dictionary
7. tuples, set &amp; dictionary
PhD Research Scholar
 
6. list
6. list6. list
5. string
5. string5. string
4. functions
4. functions4. functions
4. functions
PhD Research Scholar
 

More from PhD Research Scholar (20)

Ajax
AjaxAjax
Ajax
 
Quiz servlet
Quiz servletQuiz servlet
Quiz servlet
 
Quiz
QuizQuiz
Quiz
 
servlet db connectivity
servlet db connectivityservlet db connectivity
servlet db connectivity
 
1.java script
1.java script1.java script
1.java script
 
Quiz javascript
Quiz javascriptQuiz javascript
Quiz javascript
 
Thread&amp;multithread
Thread&amp;multithreadThread&amp;multithread
Thread&amp;multithread
 
String
StringString
String
 
Streams&amp;io
Streams&amp;ioStreams&amp;io
Streams&amp;io
 
Packages
PackagesPackages
Packages
 
Interface in java
Interface in javaInterface in java
Interface in java
 
Inner classes in java
Inner classes in javaInner classes in java
Inner classes in java
 
Inheritance
InheritanceInheritance
Inheritance
 
Exception handling
Exception handlingException handling
Exception handling
 
Applets
AppletsApplets
Applets
 
Abstract class
Abstract classAbstract class
Abstract class
 
7. tuples, set &amp; dictionary
7. tuples, set &amp; dictionary7. tuples, set &amp; dictionary
7. tuples, set &amp; dictionary
 
6. list
6. list6. list
6. list
 
5. string
5. string5. string
5. string
 
4. functions
4. functions4. functions
4. functions
 

Recently uploaded

The Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptxThe Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptx
DhatriParmar
 
The Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdfThe Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdf
kaushalkr1407
 
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
MysoreMuleSoftMeetup
 
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
EugeneSaldivar
 
Adversarial Attention Modeling for Multi-dimensional Emotion Regression.pdf
Adversarial Attention Modeling for Multi-dimensional Emotion Regression.pdfAdversarial Attention Modeling for Multi-dimensional Emotion Regression.pdf
Adversarial Attention Modeling for Multi-dimensional Emotion Regression.pdf
Po-Chuan Chen
 
special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
Special education needs
 
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCECLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
BhavyaRajput3
 
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXXPhrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
MIRIAMSALINAS13
 
The approach at University of Liverpool.pptx
The approach at University of Liverpool.pptxThe approach at University of Liverpool.pptx
The approach at University of Liverpool.pptx
Jisc
 
Operation Blue Star - Saka Neela Tara
Operation Blue Star   -  Saka Neela TaraOperation Blue Star   -  Saka Neela Tara
Operation Blue Star - Saka Neela Tara
Balvir Singh
 
Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.
Ashokrao Mane college of Pharmacy Peth-Vadgaon
 
Francesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptxFrancesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptx
EduSkills OECD
 
Embracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic ImperativeEmbracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic Imperative
Peter Windle
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
siemaillard
 
678020731-Sumas-y-Restas-Para-Colorear.pdf
678020731-Sumas-y-Restas-Para-Colorear.pdf678020731-Sumas-y-Restas-Para-Colorear.pdf
678020731-Sumas-y-Restas-Para-Colorear.pdf
CarlosHernanMontoyab2
 
Additional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdfAdditional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdf
joachimlavalley1
 
How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17
Celine George
 
The French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free downloadThe French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free download
Vivekanand Anglo Vedic Academy
 
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
Levi Shapiro
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
Pavel ( NSTU)
 

Recently uploaded (20)

The Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptxThe Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptx
 
The Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdfThe Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdf
 
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
 
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
 
Adversarial Attention Modeling for Multi-dimensional Emotion Regression.pdf
Adversarial Attention Modeling for Multi-dimensional Emotion Regression.pdfAdversarial Attention Modeling for Multi-dimensional Emotion Regression.pdf
Adversarial Attention Modeling for Multi-dimensional Emotion Regression.pdf
 
special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
 
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCECLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
 
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXXPhrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
 
The approach at University of Liverpool.pptx
The approach at University of Liverpool.pptxThe approach at University of Liverpool.pptx
The approach at University of Liverpool.pptx
 
Operation Blue Star - Saka Neela Tara
Operation Blue Star   -  Saka Neela TaraOperation Blue Star   -  Saka Neela Tara
Operation Blue Star - Saka Neela Tara
 
Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.
 
Francesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptxFrancesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptx
 
Embracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic ImperativeEmbracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic Imperative
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
 
678020731-Sumas-y-Restas-Para-Colorear.pdf
678020731-Sumas-y-Restas-Para-Colorear.pdf678020731-Sumas-y-Restas-Para-Colorear.pdf
678020731-Sumas-y-Restas-Para-Colorear.pdf
 
Additional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdfAdditional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdf
 
How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17
 
The French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free downloadThe French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free download
 
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
 

2.java script dom

  • 2. DOM Document Object Model  Every web page resides inside a browser window which can be considered as an object.  It represents the HTML document that is displayed in that window.  It has various properties that refer to other objects which allow access to and modification of document content.  This way is accessed and modified is called the Document Object Model, or DOM.  Hierarchical structure to the organization of objects in a Web document. =>
  • 3. objects in a Web document.  Window object  Document object  Form object  Form control elements
  • 4. Property & Description  Body - document.body  defaultView - document.defaultView  documentElement - document.documentElement8/31/2008  getElementById( id) - document.getElementById( id)  getElementsByName( name) - document.getElementsByName( name)  getElementsByTagName( tagname)- document.getElementsByTagName( tagname) 
  • 5. DOMs in existence <head> <title> Document Title </title> <script type="text/javascript"> <!-- function myFunc() { var ret = document.getElementsByTagName("title"); alert("Document Title : " + ret.text ); //gets the title of doc var ret = document.getElementById("heading"); alert(ret.innerHTML ); } //--> </script> </head>
  • 6. <body> <h1 id="heading">This is main title</h1> <p>Click the following to see the result:</p> <form id="form1" name="FirstForm"> <input type="button" value="Click Me" onclick="myFunc();" /> <input type="button" value="Cancel"> </form> <form d="form2" name="SecondForm"> <input type="button" value="Don't ClickMe"/> </form> </body>
  • 7. JavaScript - The Date Object  Date object is a datatype built into the JavaScript  Created with the new Date( )  new Date( )  new Date(milliseconds)  new Date(datestring)  new Date(year,month,date[, hour,minute,second,millisecond ])
  • 8. JavaScript - The Date Object <html> <head> <title>JavaScript Date Method</title> </head> <body> <script type="text/javascript"> var dt = Date(); document.write("Date and Time : " + dt ); </script> </body> </html> Output: Date and Time : Tue Aug 08 2017 17:15:06 GMT+0530 (India Standard Time)
  • 9. JavaScript – Domain example <html> <body> <p>Click the button to display the domain name of the server that loaded this document.</p> <button onclick="myFunction()">Try it</button> <p id="demo"></p> <script> function myFunction() { document.getElementById("demo").innerHTML = document.domain; } </script></body></html> Click the try button to display the domain name of the server that loaded this document. o/p: www.google.com
  • 10. JavaScript - Cookie <html> <body> <p id="demo">Click the button to display the cookies associated with this document.</p> <button onclick="myFunction()">Try it</button> <script> function myFunction() { document.getElementById("demo").innerHTML = "Cookies associated with this document: " + document.cookie; } </script></body></html> Cookies associated with this document: __gads=ID=66b36630d70e3ac5:T=1502354049:S=ALNI_Mawf4e62DiZ3EEzs_-NPMoLpCUO2Q; _gat=1; _ga=GA1.2.148245611.1502354051; _gid=GA1.2.144215362.1502354051
  • 11. JavaScript – Count Input tag <html><head> <script> function getElements() { var x = document.getElementsByTagName("input"); document.getElementById("demo").innerHTML = x.length; } </script></head><body> <input type="text" size="20"><br> <input type="text" size="20"><br> <input type="text" size="20"><br> <p> <input type="button" onclick="getElements()" value="How many input elements?“> </p> <p id="demo">Prints here:</p> </body> </html> Click How many input elements? Button o/p: 4
  • 12. JavaScript – CSS Manipulation <html> <body> <p id="p1"> This is a text. This is a text. This is a text. </p> <input type="button" value="Hide text" onclick="document.getElementById('p1').style.visibility='hidden'"> <input type="button" value="Show text" onclick="document.getElementById('p1').style.visibility='visible'"> </body> </html>