In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-21 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article is about what kind of scripting language javascript is. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.
Javascript is an event-driven scripting language. Javascript uses an event-driven mechanism to respond to user actions, that is, when a user operates on a html element, an event is generated that drives some functions to handle it.
The operating environment of this tutorial: windows7 system, javascript1.8.5 version, Dell G3 computer.
I still remember that I learned the event listening mechanism when I was learning JAVA-GUI programming, so it would be easy to learn the event-driven mechanism in JavaScript. I also drew a schematic diagram when I was studying, so start with the schematic diagram.
Js uses event-driven (event-driven) to respond to user actions. That is, when a user operates on a html element, an event is generated that drives some function to handle it.
For example, through the mouse or buttons in the browser window or web page elements (buttons, text boxes.) We call it an Event. A series of program actions triggered by a mouse or hotkey are called event-driven (Event-Driver). Event handlers or functions are called event handlers (Event Handler).
Classification of events:
Mouse event:
When the user clicks the page element with the mouse, the corresponding dom node will trigger mouse events, such as click, dblclick, mousedown, mouseout, mouseover, mouseup, mousemove and so on.
Keyboard event:
When the user enters information with the keyboard, the keyboard operation event is triggered. It mainly includes keydown, keypress and keyup.
HTML event:
Load changes and other related events on the html node, such as window's onload, unload, abort, error, text boxes select, change, and so on.
Other events:
Events generated during the operation of some special objects on the page, such as events related to the xmlhttprequest object.
Such as the following example:
As the first starter case, you will encounter a problem as follows:
The code is as follows:
Mouse event function test (e) {window.alert ("x =" + e.cientX + "y =" + e.clientY);}
It is not difficult to find that when we do not set the width and height of the body, the range of the body is only a line, so the onmousedown event cannot respond. So, after setting the width and height of the body, we can respond to the onmousedown event in the width and height range of the body.
How to understand event-driven mechanism
To further understand the event-driven mechanism of js, let's take a look at two examples:
Case: display a button, click the button and pop up a dialog box showing the current time.
Mouse event function test1 () {window.alert (new Date (). ToLocaleString ());}
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.