JS Learning Note----Event object

Source: Internet
Author: User

Event: Events Object, when an event occurs, some detailed information about the event that occurs with the current object is temporarily saved to a specified place-event object, which we can call when needed.

the event object must be used inside a function called by an event to have content. Event function: A function called by an event, a function is not an event function, it is not determined at the time of definition, but depends on the time of the function call.

compatible with:Ie/choreme:event is a built-in global object. Standard Browser: The event object is passed in by the first parameter of the event function.

If a function is called by an event, then the first parameter defined by the function is the event object. Example code:
1 <!DOCTYPE HTML>2 <HTMLLang= "en">3     <Head>4         <title>Event Object</title>5         <MetaCharSet= "UTF-8">6         <Metaname= "Viewport"content= "Width=device-width, initial-scale=1">7         <Script>8             9             functionfn1 (EV) {Ten                 varEV=EV||event;//compatible wording One                 for(varattrinchev) { A Console.log (attr+ '=' +ev[attr]); //Traverse All Events -                } -             } the fn1 ();//function not called by event - Document.onclick=fn1;//is the function called by the event -  -              +         </Script> -     </Head> +     <Body> A      at     </Body> - </HTML>

  

JS Learning Note----Event object

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.