Java Script and HTML.
-
Upload
akshat-vig -
Category
Automotive
-
view
1.448 -
download
0
Transcript of Java Script and HTML.
![Page 1: Java Script and HTML.](https://reader031.fdocuments.net/reader031/viewer/2022022414/58784dd51a28ab68198b5b3d/html5/thumbnails/1.jpg)
SLICING AND PLAYING
WITH HTML
Learning Java Script Editing
![Page 2: Java Script and HTML.](https://reader031.fdocuments.net/reader031/viewer/2022022414/58784dd51a28ab68198b5b3d/html5/thumbnails/2.jpg)
What is it?
Slicing HTML involves playing with the stuff on the
HTML Page like “divs”, “select boxes”, “input boxes”
and much-much more
![Page 3: Java Script and HTML.](https://reader031.fdocuments.net/reader031/viewer/2022022414/58784dd51a28ab68198b5b3d/html5/thumbnails/3.jpg)
Some key points
Every element is associated with the ID. ID is used to
access that object on the HTML page. And
document.getElementById(“element_name”) will give
you the power to access that element on the page.
Now you are just one step away from
altering/modifying the HTML page.
![Page 4: Java Script and HTML.](https://reader031.fdocuments.net/reader031/viewer/2022022414/58784dd51a28ab68198b5b3d/html5/thumbnails/4.jpg)
Key Points Cont…
document.getElementByTagsName(“div”) will give
you all the divs on the page. Again one step away
from editing the page. Isnt is simple?
![Page 5: Java Script and HTML.](https://reader031.fdocuments.net/reader031/viewer/2022022414/58784dd51a28ab68198b5b3d/html5/thumbnails/5.jpg)
Key Points Cont…
Inner HTML can be used to set the content of the
page. The good/bad thing about Inner html is that
it over writes what ever content is already
associated with that element.
Inner HTML replaces (over rides) already existing
conetnt.
![Page 6: Java Script and HTML.](https://reader031.fdocuments.net/reader031/viewer/2022022414/58784dd51a28ab68198b5b3d/html5/thumbnails/6.jpg)
Document Object Model
<html>
<head></head>
<body>
<p id=”story”>
Hey
<strong>Akshat</strong>
</p>
</body>
</html>
![Page 7: Java Script and HTML.](https://reader031.fdocuments.net/reader031/viewer/2022022414/58784dd51a28ab68198b5b3d/html5/thumbnails/7.jpg)
Main Properties to consider in the Dom
tree
nodeValue
nodeType
firstChild
lastChild
childNodes
![Page 8: Java Script and HTML.](https://reader031.fdocuments.net/reader031/viewer/2022022414/58784dd51a28ab68198b5b3d/html5/thumbnails/8.jpg)
What this refers to in the HTML
Document.getElementByTagsName(“body”)[0].child
Nodes[1].lastChild.
Answer :- strong.
Refer slide number 6 for HTML
![Page 9: Java Script and HTML.](https://reader031.fdocuments.net/reader031/viewer/2022022414/58784dd51a28ab68198b5b3d/html5/thumbnails/9.jpg)
Changing the node text
var node = document.getElementBId(“story”);
while(node.firstchild)
node.removechild(node.firstchild);
node.appendchild(document.createTextNode(“OK
Finally”));
![Page 10: Java Script and HTML.](https://reader031.fdocuments.net/reader031/viewer/2022022414/58784dd51a28ab68198b5b3d/html5/thumbnails/10.jpg)
Creating a new Element
var paragraph =document.createElement(p) – Just
specify the tag name here
paragraph.appendchild(document.createTextNode(“T
he text in the paragraph”));
document.getElementbyId(“story”).appendchild(parag
raph);
![Page 11: Java Script and HTML.](https://reader031.fdocuments.net/reader031/viewer/2022022414/58784dd51a28ab68198b5b3d/html5/thumbnails/11.jpg)