Document Object Model (DOM)

30 287 0
Document Object Model (DOM)

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

Thông tin tài liệu

Document Object Model (DOM) Computer Science & Engineering LOGO LOGO HTML DOM 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 window document event frame history location navigator screen document form button check box hidden password radio csehui.wordpress.com reset select submit text textarea anchor applet class element embeb ID image layer link plug-in style tag Computer Science & Engineering LOGO CREATING OBJECTS Define the function: function ObjectName(List Parameter) { this.property1= Parameter1; this.property2= Parameter2; … this.method1=functionName1; this.method2=functionName2; … } csehui.wordpress.com Computer Science & Engineering LOGO CREATING OBJECTS To call object we use the keyword new Exemple: function myobject() { this.containedValue = 0; this.othercontainedValue = 0; this.anothercontainedValue = 0; } var mything = new myobject(); csehui.wordpress.com Computer Science & Engineering ARRAY OBJECT LOGO Array: An array is a special variable, which can hold more than one value, at a time An array can be defined in three ways:  var myCars=new Array(); myCars[0]="Saab"; myCars[1]="Volvo"; myCars[2]="BMW";  var myCars=new Array("Saab","Volvo","BMW");  var myCars=["Saab","Volvo","BMW"]; csehui.wordpress.com Computer Science & Engineering ARRAY OBJECT LOGO Array Object Properties Ex: var fruits = ["Banana", "Orange", "Apple", "Mango"]; document.write("Original length: " + fruits.length); csehui.wordpress.com Computer Science & Engineering ARRAY OBJECT LOGO Array Object Methods csehui.wordpress.com Computer Science & Engineering DATE OBJECT LOGO Date Object: The Date object is used to work with dates and times  Date objects are created with new Date()  There are four ways of instantiating a date: var d = new Date(); var d = new Date(milliseconds); var d = new Date(dateString); var d = new Date(year, month, day, hours, minutes, seconds, milliseconds); csehui.wordpress.com Computer Science & Engineering DATE OBJECT LOGO Date Object Methods csehui.wordpress.com Computer Science & Engineering DATE OBJECT LOGO Date Object Methods csehui.wordpress.com Computer Science & Engineering FORM OBJECT LOGO Form Object Properties csehui.wordpress.com Computer Science & Engineering FORM OBJECT LOGO Form elements Collection  The elements collection returns an array containing each element in the form Syntax  formObject.elements[].property csehui.wordpress.com Computer Science & Engineering LOGO FORM OBJECT EX: Firstname: Lastname:

Get the value of all the elements in the form: var x=document.getElementById("myForm"); for (var i=0;i

Ngày đăng: 13/05/2014, 19:51

Từ khóa liên quan

Tài liệu cùng người dùng

  • Đang cập nhật ...

Tài liệu liên quan