JavaScript Daily Learning 4

Source: Internet
Author: User

JavaScript events

1, <button id= "btn1" onclick="document.getElementById (" Btn1 "). Innertext=date ();" > What's the time now? </button>

    2, <button onclick= "this.innerHTML= Date () "> What's the time now? </button>

    3, <button id= "btn1 " onclick= "display_type () " > What time Is it now? </button>

         < Script>

                       function Display_type () {

                              document.getElementById ("Btn1"). Innertext=date ();

                     

</script>

Common HTML events for JavaScript

The following is a list of some common HTML events:

Events Description
OnChange HTML element Changes
OnClick User clicks on HTML element
onmouseover The user moves the mouse over an HTML element
onmouseout The user moves the mouse away from an HTML element
OnKeyDown The user presses the keyboard key
OnLoad The browser has finished loading the page

JavaScript scopes

Events can be used to process form validation, user input, user behavior, and browser actions:

    • Trigger event when page loads
    • Trigger event when page closes
    • The user clicks the button to perform the action
    • Verifying the legality of user input
    • Wait a minute...

You can use several methods to execute JavaScript event code:

    • HTML Event Properties can execute JavaScript code directly
    • HTML Event Properties can call JavaScript functions
    • You can specify your own event handlers for HTML elements
    • You can stop the event from happening.
    • Wait a minute...

JavaScript Daily Learning 4

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.