javascript object
1. What is a form object?
Form (
3. Properties of the form objectAttribute description
encoding Default is text/htmlmethod "Get" or " Post”
elements
Array
Read-only, the index of all objects in the form, 0,1,…
You can know how many objects the form has by document.formname.elements.length
Here the elements attribute is a An array whose elements correspond to controls within the form on the page. In addition to elements, several other attributes of the form correspond to the attributes of the
mark in HTML syntax. 4. Examples of using form objects If you use the form object in the following example, the effect and code are as follows: <script> <p>function display(){ <p>var str; <p>// 使用表单名称访问表单对象的属性 <p>str="name="+document.form1.name+"\r"; <p>str=str+"action="+document.form1.action+"\r"; <p>str=str+"method="+document.form1.method+"\r"; <p>//访问表单对象的elements数组 <p>str=str+"elements:"+"\r"; <p>for(var i=0;i<document.form1.elements.length;i++){ <p>str=str+ " "+document.form1.elements[i].type <p>+"\t"+document.form1.elements[i].name <p>+"\t"+document.form1.elements[i].value+"\r"; <p>} <p>window.alert(str); <p>return false; <p>} <p>function submitform(){ <p>//使用表单数组+下标访问表单对象 <p>document.forms[0].submit(); <p>} <p></script> alt Sets or returns the alternative text that is displayed when the browser does not support text fields. defaultValue Sets or returns the default value of the text field. disabled Sets or returns whether the text field should be disabled. id Sets or returns the id of the text field. maxLength Sets or returns the maximum number of characters in the text field. name Sets or returns the name of the text field. readOnly Sets or returns whether the text field should be read-only. size Sets or returns the size of the text field. tabIndex sets or returns the tab key control order of the text field.type Returns the form element type of the text field.
value 设置或返回文本域的 value 属性的值。
方法blur( ) 将当前焦点移到后台
select( ) 加亮文字,选取文本域中的内容。
focus() 在文本域上设置焦点。
主要事件onfocus,onblur,onselect,onchange
text对象使用示例如下:
<script> </script>
document.form1.text1.value="this is a javascirpt";
document.form1.text1.select();
alert(document.form1.text1.value);
document.text1.blur();
2、textarea对象
textarea对象对应于页面中的textarea输入控件。
属性name textarea输入框控件名称
value textarea输入框控件中当前的文本
defaultvalue textarea输入框控件的默认文本
方法blur( ) 将当前焦点移到后台
select( ) 加亮文字
主要事件onfocus,onblur,onselect,onchange
3、select对象
select对象对应于网页中的下拉列表框。
…………
属性disabled 设置或返回是否应禁用下拉列表
id 设置或返回下拉列表的 id。
length 返回下拉列表中的选项数目。
multiple 设置或返回是否选择多个项目。
name 设置或返回下拉列表的名称。
options
数组
返回包含下拉列表中的所有选项(option对象)的一个数组。
其中option对象包括如下属性:
text 该选项显示的文字
value 该选项的value值
selected 指明该选项是否别选中
selectedIndex 当前选中项的下标
size 设置或返回下拉列表中的可见行数。
方法options.add() 向下拉列表添加一个选项。
blur() 从下拉列表移开焦点。
focus() 在下拉列表上设置焦点。
remove() 从下拉列表中删除一个选项。
主要事件onfocus,onblur,onchange
4、button对象
button对象对应于网页中的按钮控件。
属性accessKey 设置或返回访问按钮的快捷键。
alt 设置或返回当浏览器无法显示按钮时供显示的替代文本。
disabled 设置或返回是否禁用按钮。
id 设置或返回按钮的 id。
name 设置或返回按钮的名称。
tabIndex 设置或返回按钮的 tab 键控制次序。
value 设置或返回在按钮上显示的文本。
方法blur() 把焦点从元素上移开。
click() 在该按钮上模拟一次鼠标单击。
focus() 为该按钮赋予焦点。
主要事件onclick
5、checkbox对象
checkbox对象对应于网页中的复选框。
选项说明
属性accessKey 设置或返回访问 checkbox 的快捷键。
alt 设置或返回不支持 checkbox 时显示的替代文本。
checked 设置或返回 checkbox 是否应被选中。
defaultChecked 返回 checked 属性的默认值。
disabled 设置或返回 checkbox 是否应被禁用。
id 设置或返回 checkbox 的 id。
name 设置或返回 checkbox 的名称。
tabIndex 设置或返回 checkbox 的 tab 键控制次序。
value 设置或返回 checkbox 的 value 属性的值
方法blur() 从 checkbox 上移开焦点
click() simulates a mouse click in the checkbox.
focus() gives focus to checkbox.
Main event onclick
6. Radio object
The radio object corresponds to the radio control in the web page. When there are multiple radio controls with the same name in the web page, an array of
radio objects is formed, in which each radio control is a radio object.
Option Description
Option Description
…………
Attribute accessKey Sets or returns the shortcut key for accessing the radio button.
alt Sets or returns the alternative text displayed when the radio button is not supported.
checked Sets or returns the status of the radio button.
defaultChecked Returns the default state of the radio button.
disabled Sets or returns whether the radio button is disabled.
id Sets or returns the id of the radio button.
name Sets or returns the name of the radio button.
tabIndex sets or returns the tab key control order of radio buttons.
value Sets or returns the value of the radio button’s value attribute.
Method blur() removes focus from radio button.
click() simulates a mouse click on a radio button.
focus() gives focus to the radio button.
Main event onclick
7. hidden object
The hidden object corresponds to the hidden domain in the web page.
Attribute alt Sets or returns the alternative text displayed when hidden input fields are not supported.
id Sets or returns the id of the hidden domain.
name Sets or returns the name of the hidden domain.
value sets or returns the value of the value attribute of the hidden field.
8. Submit object
The submit object corresponds to the submit button in the web page.
Attribute accessKey Sets or returns the shortcut key to access the submit button.
alt Sets or returns the alternative text to be displayed when the browser does not support the submit button.
disabled Sets or returns whether the submit button should be disabled.
id Sets or returns the id of the submit button.
name Sets or returns the name of the submit button.
tabIndex sets or returns the tab key control order of the submit button.
value Sets or returns the text displayed on the submit button.
Method blur() removes focus from the submit button.
click() simulates a mouse click on the submit button.
focus() gives focus to the submit button.
Main event onclick
9. Password object
The password object corresponds to the password input box in the web page.
Attribute accessKey Sets or returns the shortcut key for accessing the password field.
alt Sets or returns the alternative text displayed when the password field is not supported.
defaultValue Sets or returns the default value of the password field.
disabled Sets or returns whether the password field should be disabled.
id Sets or returns the id of the password field.
maxLength Sets or returns the maximum number of characters in the password field.
name Sets or returns the name of the password field.
readOnly Sets or returns whether the password field should be read-only.
size Sets or returns the length of the password field.
tabIndex sets or returns the tab key control order of the password field.
value Sets or returns the value of the value attribute of the password field.
Method blur() Removes focus from the password field.
click() gives focus to the password field.
focus() Select the text in the password field.
Main events onfocus, onblur, onselect, onchange
*History object
The History object contains the URLs visited by the user (in the browser window).
The History object is part of the window object and can be accessed through the window.history property.
History Object Properties
Property Description
length returns the number of URLs in the browser history list.
History Object Method
Method Description
back() Loads the previous URL in the history list.
forward() loads the next URL in the history list.
go(number|URL) loads a specific page in the history list.
-1 means the previous page

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



Face detection and recognition technology is already a relatively mature and widely used technology. Currently, the most widely used Internet application language is JS. Implementing face detection and recognition on the Web front-end has advantages and disadvantages compared to back-end face recognition. Advantages include reducing network interaction and real-time recognition, which greatly shortens user waiting time and improves user experience; disadvantages include: being limited by model size, the accuracy is also limited. How to use js to implement face detection on the web? In order to implement face recognition on the Web, you need to be familiar with related programming languages and technologies, such as JavaScript, HTML, CSS, WebRTC, etc. At the same time, you also need to master relevant computer vision and artificial intelligence technologies. It is worth noting that due to the design of the Web side

With the rapid development of Internet finance, stock investment has become the choice of more and more people. In stock trading, candle charts are a commonly used technical analysis method. It can show the changing trend of stock prices and help investors make more accurate decisions. This article will introduce the development skills of PHP and JS, lead readers to understand how to draw stock candle charts, and provide specific code examples. 1. Understanding Stock Candle Charts Before introducing how to draw stock candle charts, we first need to understand what a candle chart is. Candlestick charts were developed by the Japanese

Here's how to convert a MySQL query result array into an object: Create an empty object array. Loop through the resulting array and create a new object for each row. Use a foreach loop to assign the key-value pairs of each row to the corresponding properties of the new object. Adds a new object to the object array. Close the database connection.

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

In PHP, an array is an ordered sequence, and elements are accessed by index; an object is an entity with properties and methods, created through the new keyword. Array access is via index, object access is via properties/methods. Array values are passed and object references are passed.

The Request object in PHP is an object used to handle HTTP requests sent by the client to the server. Through the Request object, we can obtain the client's request information, such as request method, request header information, request parameters, etc., so as to process and respond to the request. In PHP, you can use global variables such as $_REQUEST, $_GET, $_POST, etc. to obtain requested information, but these variables are not objects, but arrays. In order to process request information more flexibly and conveniently, you can

The relationship between js and vue: 1. JS as the cornerstone of Web development; 2. The rise of Vue.js as a front-end framework; 3. The complementary relationship between JS and Vue; 4. The practical application of JS and Vue.

Introduction to the method of obtaining HTTP status code in JavaScript: In front-end development, we often need to deal with the interaction with the back-end interface, and HTTP status code is a very important part of it. Understanding and obtaining HTTP status codes helps us better handle the data returned by the interface. This article will introduce how to use JavaScript to obtain HTTP status codes and provide specific code examples. 1. What is HTTP status code? HTTP status code means that when the browser initiates a request to the server, the service
