Common methods of JS

Source: Internet
Author: User

Event (Event listener):

The label object. Event listener. Function () {Execute code, find object, Find property, change property};
The event source. Triggers an event. Call a method. Method find the execution code to find the object, find properties, change attributes (or use attributes, additions and deletions to change)
onmouseover Mouse moves over an element
onmouseout mouse away from an element
onkeydown Keyboard Press down (just keep pressing)
onkeypress Keyboard Press down and then release (just click Down and then release)
oonkeyup Keyboard Release (when it is loosened)
onclick Mouse Press down and then up (click)
onmousedown mouse button pressed (press not move)
onmousemove Mouse movement (moving and not pressing)
onmouseout Mouse over an element (when mouse is on)
onmouseup mouse button release (when Mouse is released)
onresize window or frame is resized
window.onresize
onsubmit form Submission
onblur element loses focus
onfocus Element gets focus
width and height of the browser's blank area (ie, browser width and height)
width: document.documentElement.clientWidth;
High: document.documentElement.clientHeight;

How to get Objects:
window.document.getElementById (' Miao ');//window can be omitted
document.getElementById (' Miao ');//id is unique, not conflicting, so gets an object value, not an array
document.getElementsByTagName ("a");//tag name is not unique get all a tag object, generate array
Document.getelementsbyclassname ("a");//classname is not unique, gets all the classname for a label object to generate an array
Document.getelementsbyname ("a");//name property is not unique, gets all label objects with Name A, generates an array
is the entire label .

after you get the object, you can call the object's innerHTML property if you want to get the contents of the tag
The label object. InnerHTML: Represents the text between tags
The Label object. InnerHTML = new data: The assignment of content between tags


Bullet Box:

alert (): A regular pop-up window
confirm (): pops up a popup with confirmation and cancellation
prompt (): Popup with Input box
setTimeout (func,n);//timer, n seconds after executing the program in Func, in milliseconds


Common methods of JS

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.