Basics: How to use JavaScript in your HTML?

Source: Internet
Author: User
Tags html tags key
Javascript

JavaScript to achieve the dynamic effect of HTML, usually called Web effects, in this website special effects column code more! So how do you add Javsscript to the HTML?

JavaScript is a client-side scripting language that works with HTML, but this is not a javsscript guide, and we look at how JavaScript is used in HTML.

JavaScript events are used like attributes of HTML tags. An event is something that occurs on an HTML element, such as when it was clicked or when the focus was lost.

<a href= "#top" >click me</a>

The events that can be used are:

onblur (used in form elements, executed when the element loses focus)
onchange (used in form elements, when something changes to be performed)
OnClick (executes when mouse clicks an element)
OnDblClick (executes when the mouse double-clicks an element)
onfocus (used in form elements, executed when the element gets focus)
OnKeyDown (performed when a key is pressed)
onkeypress (executes when a key is pressed and released)
OnKeyUp (performed when a key is released)
OnLoad (used in the body tag, when loading the page to execute)
OnMouseDown (performed when the mouse button is pressed)
OnMouseMove (executes when the mouse cursor is moved over the element)
onMouseOut (executes when the mouse cursor moves away from the element)
onMouseOver (executes when the mouse cursor moves over the element)
OnMouseUp (performed when mouse button is released)
OnReset (used in form elements, executed when form resets)
Onselect (used in form elements, executed when element is selected)
OnSubmit (used in form elements, executed when form is submitted)
OnUnload (used in the Body tab, when the page is closed)
Shout, Finish ...

Attention

Don't lose control of JavaScript. It's best to use less. A Web page that uses JavaScript has the risk of significantly reducing usability, and many things can replace it, such as the server-side scripting language PHP or ASP.



Related Article

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.