1024programmer JavaScript Explain DOM elements and events in detail

Explain DOM elements and events in detail

1, mouse event

onclick //click
 ondblclick //double click
 onmouseover //mouse moves in
 onmouseout //mouse out
 onmousemove //Mouse movement

2. The document or element is loaded:

onload //The element or document is loaded

3. Form control state monitoring:

onfocus //The text box gets the focus
 onblur //The text box loses focus
 oninput //Real-time monitoring input
 onchange //Triggered when the input content changes twice, or when the element state changes
 onsubmit //form element monitoring, trigger after clicking the submit button, control whether the data can be sent to the server through the return value

Second, get the element node

1 , Get the list of element nodes according to the tag name

var elems = document.getElementsByTagName("");
 /*parameter: label name
 Return value: node list, you need to get the specific element node object from the node list, and add the corresponding subscript.
 */

2. Obtain the element node list according to the class attribute value

1. Inline method: bind the event name as a label attribute to the element

Example:

2 , Dynamic binding: Get element nodes, dynamically add events

Example:

btn.Onclick= function (){
 };

Recommended tutorial: js introductory tutorial

The above is the detailed content of DOM elements and events. For more, please pay attention to other related articles on 1024programmer.com!

This article is from the internet and does not represent1024programmerPosition, please indicate the source when reprinting:https://www.1024programmer.com/explain-dom-elements-and-events-in-detail/

author: admin

Previous article
Next article

Leave a Reply

Your email address will not be published. Required fields are marked *

Contact Us

Contact us

181-3619-1160

Online consultation: QQ交谈

E-mail: [email protected]

Working hours: Monday to Friday, 9:00-17:30, holidays off

Follow wechat
Scan wechat and follow us

Scan wechat and follow us

Follow Weibo
Back to top
首页
微信
电话
搜索