Home Web Front-end JS Tutorial Other Objects in JavaScript_Basics

Other Objects in JavaScript_Basics

May 16, 2016 pm 07:06 PM
javascript

anchors[]; links[]; Link connection object
usage: document.anchors[[x]]; document.links[[x]]; ;
Document.anchors is an array , including all anchor tags in the document ( tags containing the name attribute), and a subscript is defined for each anchor tag starting from 0 according to the order in the document.
Document.links is also an array, containing all link tags in the document (including the
tag of the href attribute and the tag in the tag segment), in order in the document, starting from 0 An index is defined for each connection tag.
If a
tag has both name and href attributes, it is both an Anchor object and a Link object.
In IE, if you add the "id="..."" attribute to the
tag, the object will be assigned an identity (ID). When calling this object, you only need to use "” That’s it. Many document components can use this method to assign IDs, but be careful that no two IDs are the same.
anchors and links are arrays and have array properties and methods. A single Anchor object has no properties; the properties of a single Link object are shown below.

Attributes
protocol; hostname; port; host; pathname; hash; search; href are the same as location objects.
target returns/specifies the target window (string) of the connection, which is the same as the target attribute in the
tag.
Event
onclick; onmouseover; onmouseout; onmousedown; onmouseup

applets[] Java applet object It is an array that contains all Applet objects (Java applet) in the document. As an array, there are array properties and methods. Regarding the properties and methods of a single Applet object, I quote: "The Applet object inherits all public properties and methods of the Java applet." (English original sentence: The Applet object inherits all public properties of the Java applet./The Applet object inherits all public methods of the Java applet.) Because I hate Java applets, I am not interested in its "public" and "private" issues, so I did not discuss them.
embeds[] Plug-in object It is an array that contains all plug-ins ( tags) in the document. Because each plug-in is different, each Embed object also has different properties and methods.
forms[]; Form form object document.forms[] is an array that contains all the forms in the document (

). To reference a single form, you can use document.forms[x], but generally speaking, people will do this: add the "name="..."" attribute to the
tag, then directly use "document." can be quoted.

Attributes of the Form object
name returns the name of the form, which is the
attribute.
action returns/sets the submission address of the form, which is the
attribute.
method returns/sets the form submission method, which is the
attribute.
target returns/sets the window returned after the form is submitted, which is the
attribute.
encoding returns/sets the encoding method of form submission content, which is the
attribute.
length returns the number of elements contained in the form.
Method
reset() resets the form. This is the same as pressing the "reset" button.
submit() submits the form. This is the same as pressing the "Submit" button.
Event
onreset; onsubmit

The following from "Button" to "Textarea" are all element objects of the form.
Button button object is specified by "". To reference a Button object, you can use "..". refers to the value of the "name="..."" attribute in the tag. You can use this method to reference any form element.

Attribute
name Returns/sets the name of the element specified with .
value returns/sets the value of the element specified with .
form returns the form object containing this element.
Method
blur() removes focus from an object.
focus() gives the object focus.
click() simulates a mouse click on the object.
Event
onclick; onmousedown; onmouseup

Checkbox checkbox object specified by "".

Attribute
name Returns/sets the name of the element specified with .
value returns/sets the value of the element specified with .
form returns the form object containing this element.
checked returns/sets whether the checkbox object is checked. This is a boolean value.
defaultChecked returns/sets whether the checkbox object is checked by default. This is a boolean value.
Method
blur() removes focus from an object.
focus() gives the object focus.
click() simulates a mouse click on the object.
Event
onclick

elements[]; Element form element object .elements is an array that contains all the objects of the form. Generally we do not use this array, but directly reference each specific object.
Hidden Hidden objects are specified by "".

Attribute
name Returns/sets the name of the element specified with .
value returns/sets the value of the element specified with .
form returns the form object containing this element.

Password Password input area object is specified by "".

Attribute
name Returns/sets the name of the element specified with .
value returns/sets the current value of the password input area.
defaultValue returns the default value specified with .
form returns the form object containing this element.
Method
blur() removes focus from an object.
focus() gives the object focus.
select() selects all the text in the password input area.
Event
onchange

Radio radio field object specified by "". A group of Radio objects have a common name (name attribute), so document.formName.radioName becomes an array. To access a single Radio object use: document.formName.radioName[x].

Attributes of a single Radio object
name returns/sets the name of the element specified with .
value returns/sets the value of the element specified with .
form returns the form object containing this element.
checked returns/sets whether the radio field object is selected. This is a boolean value.
defaultChecked returns/sets whether the object is selected by default. This is a boolean value.
Method
blur() removes focus from an object.
focus() gives the object focus.
click() simulates a mouse click on the object.
Event
onclick

Reset reset button object specified by "". Because Reset is also a button, it also has properties and methods of Button objects. As for the "onclick" event, it is generally replaced by onreset of the Form object.
Select selection area (drop-down menu, list) object is specified by ".
length returns the number of options under the Select object.
selectedIndex returns the index of the selected option. This subscript is the position of the option in the options[] array. If the Select object allows multiple selections, returns the index of the first selected option.
form returns the form object containing this element.
Method
blur() removes focus from an object.
focus() gives the object focus.
Event
onchange

options[]; Option selection object options[] is an array that contains Option objects under the same Select object. Option objects are specified by ". Because Submit is also a button, it also has the properties and methods of Button object. As for the "onclick" event, it is generally replaced by onsubmit of the Form object.
Text text The box object is specified by "". The Password object is also a type of Text object, so all the properties, methods and events of the Password object are available in the Text area object. "Specify. All the properties, methods and events of the Textarea object are the same as the Text object, that is, the same as the Password object.
images[]; Image image object document.images[] is an array that contains all the images in the document (

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to implement an online speech recognition system using WebSocket and JavaScript How to implement an online speech recognition system using WebSocket and JavaScript Dec 17, 2023 pm 02:54 PM

How to use WebSocket and JavaScript to implement an online speech recognition system Introduction: With the continuous development of technology, speech recognition technology has become an important part of the field of artificial intelligence. The online speech recognition system based on WebSocket and JavaScript has the characteristics of low latency, real-time and cross-platform, and has become a widely used solution. This article will introduce how to use WebSocket and JavaScript to implement an online speech recognition system.

WebSocket and JavaScript: key technologies for implementing real-time monitoring systems WebSocket and JavaScript: key technologies for implementing real-time monitoring systems Dec 17, 2023 pm 05:30 PM

WebSocket and JavaScript: Key technologies for realizing real-time monitoring systems Introduction: With the rapid development of Internet technology, real-time monitoring systems have been widely used in various fields. One of the key technologies to achieve real-time monitoring is the combination of WebSocket and JavaScript. This article will introduce the application of WebSocket and JavaScript in real-time monitoring systems, give code examples, and explain their implementation principles in detail. 1. WebSocket technology

How to use JavaScript and WebSocket to implement a real-time online ordering system How to use JavaScript and WebSocket to implement a real-time online ordering system Dec 17, 2023 pm 12:09 PM

Introduction to how to use JavaScript and WebSocket to implement a real-time online ordering system: With the popularity of the Internet and the advancement of technology, more and more restaurants have begun to provide online ordering services. In order to implement a real-time online ordering system, we can use JavaScript and WebSocket technology. WebSocket is a full-duplex communication protocol based on the TCP protocol, which can realize real-time two-way communication between the client and the server. In the real-time online ordering system, when the user selects dishes and places an order

How to implement an online reservation system using WebSocket and JavaScript How to implement an online reservation system using WebSocket and JavaScript Dec 17, 2023 am 09:39 AM

How to use WebSocket and JavaScript to implement an online reservation system. In today's digital era, more and more businesses and services need to provide online reservation functions. It is crucial to implement an efficient and real-time online reservation system. This article will introduce how to use WebSocket and JavaScript to implement an online reservation system, and provide specific code examples. 1. What is WebSocket? WebSocket is a full-duplex method on a single TCP connection.

JavaScript and WebSocket: Building an efficient real-time weather forecasting system JavaScript and WebSocket: Building an efficient real-time weather forecasting system Dec 17, 2023 pm 05:13 PM

JavaScript and WebSocket: Building an efficient real-time weather forecast system Introduction: Today, the accuracy of weather forecasts is of great significance to daily life and decision-making. As technology develops, we can provide more accurate and reliable weather forecasts by obtaining weather data in real time. In this article, we will learn how to use JavaScript and WebSocket technology to build an efficient real-time weather forecast system. This article will demonstrate the implementation process through specific code examples. We

Simple JavaScript Tutorial: How to Get HTTP Status Code Simple JavaScript Tutorial: How to Get HTTP Status Code Jan 05, 2024 pm 06:08 PM

JavaScript tutorial: How to get HTTP status code, specific code examples are required. Preface: In web development, data interaction with the server is often involved. When communicating with the server, we often need to obtain the returned HTTP status code to determine whether the operation is successful, and perform corresponding processing based on different status codes. This article will teach you how to use JavaScript to obtain HTTP status codes and provide some practical code examples. Using XMLHttpRequest

How to use insertBefore in javascript How to use insertBefore in javascript Nov 24, 2023 am 11:56 AM

Usage: In JavaScript, the insertBefore() method is used to insert a new node in the DOM tree. This method requires two parameters: the new node to be inserted and the reference node (that is, the node where the new node will be inserted).

JavaScript and WebSocket: Building an efficient real-time image processing system JavaScript and WebSocket: Building an efficient real-time image processing system Dec 17, 2023 am 08:41 AM

JavaScript is a programming language widely used in web development, while WebSocket is a network protocol used for real-time communication. Combining the powerful functions of the two, we can create an efficient real-time image processing system. This article will introduce how to implement this system using JavaScript and WebSocket, and provide specific code examples. First, we need to clarify the requirements and goals of the real-time image processing system. Suppose we have a camera device that can collect real-time image data

See all articles