The Document Object Model is a platform- and language-neutral interface that will allow programs and scripts to dynamically access and update the content, structure and style of documents. In this chapter we will learn with Document Object Model, inviting you to refer.
Trang 1Document Object Model (DOM)
Trang 2HTML DOM
language-neutral interface that will allow programs and scripts to dynamically access and update the content, structure and style of
password text
Trang 3CREATING OBJECTS
Define the function:
function ObjectName(List Parameter) {
this.property1= Parameter1;
this.property2= Parameter2;
… this.method1=functionName1;
this.method2=functionName2;
… }
Trang 5ARRAY OBJECT
Array: An array is a special variable, which can
hold more than one value, at a time
Trang 6ARRAY OBJECT
Array Object Properties
Ex:
var fruits = ["Banana", "Orange", "Apple", "Mango"];
document.write("Original length: " + fruits.length);
Trang 7ARRAY OBJECT
Array Object Methods
Trang 8DATE OBJECT
Date Object: The Date object is used to work with
dates and times
var d = new Date(year, month, day, hours,
minutes, seconds, milliseconds);
csehui.wordpress.com Computer Science & Engineering
Trang 9DATE OBJECT
Date Object Methods
Trang 10DATE OBJECT
Date Object Methods
Trang 11MATH OBJECT
mathematical tasks
of Math can be called by using Math as an object, without creating it
var x = Math.PI; // Returns PI
var y = Math.sqrt(16); // Returns the square root of
16
Trang 12MATH OBJECT
Math Object Methods
Trang 14MATH OBJECT
String Object Methods
Trang 15FORM OBJECT
Form:
– For each instance of a <form> tag in an HTML document, a Form object is created
Form Object Methods
Trang 16FORM OBJECT
Form Object Properties
Trang 17FORM OBJECT
Form elements Collection
containing each element in the form
Syntax
Trang 19FORM OBJECT
Button Object: The Button object represents a
button in an HTML form
For each instance of an <input type="button"> tag
in an HTML form, a Button object is created
elements[] array of the form, or by using
document.getElementById()
Trang 20FORM OBJECT
Button Object Properties
Trang 21FORM OBJECT
Button Object Methods
Trang 22FORM OBJECT
Select Object
an HTML form
form, a Select object is created
through the elements[] array of the form, or by using document.getElementById()
Trang 23FORM OBJECT
Select Object Properties
Trang 24FORM OBJECT
Select Object Methods
Trang 25through the elements[] array of the form, or by using document.getElementById()
Trang 26FORM OBJECT
Radio Object Properties
Trang 27FORM OBJECT
Radio Object Methods
Trang 28FORM OBJECT
Text Object
– The Text object represents a text-input field in
an HTML form
– For each instance of an <input type="text"> tag
in an HTML form, a Text object is created
through the elements[] array of the form, or by using document.getElementById()
Trang 29FORM OBJECT
Text Object Properties
Trang 30FORM OBJECT
Text Object Methods
document.getElementById('text1').blur()
</script>