JavaScript common tags and methods summarize _javascript tips

Source: Internet
Author: User

What is JavaScript?

(1) JavaScript is a scripting language that is object-based (object) and event driven (driven) and has a secure performance.

(2) JavaScript is a scripting language developed by Netscape, whose programs can be embedded in HTML pages and interpreted directly in the browser.

(3) JavaScript can be directly interpreted by the browser execution, it can better reduce the server pressure, improve the efficiency of program operation.

Events (event monitoring):

The Label object. Event listener. Function () {Execute code, find object, find attribute, change attribute};

The event source. Invokes a method. method to find the execution code to find the object, find attributes, change attributes (or use attributes, additions and deletions to check)

onmouseover Mouse over an element

onmouseout mouse to remove an element

onkeydown Keyboard Press down (just keep pressing)

onkeypress Keyboard Press down and loosen (just click and then loosen)

Oonkeyup keyboard Release (when released)

OnClick Mouse Press down and up (click)

OnMouseDown mouse button Press (press not move)

OnMouseMove Mouse Movement (move and do not press the line)

onMouseOut the mouse over an element (when the mouse is put up)

OnMouseUp mouse button is released (when the mouse is loosened)

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, the width and height of the browser)

Width: document.documentElement.clientWidth;

High: Document.documentElement.clientHeight;

How to get an object:

Window.document.getElementById (' Miao ');//window can omit

document.getElementById (' Miao ');//id is unique, not conflicting, so get an object value, not an array

document.getElementsByTagName ("a");//label name not unique get all a tag objects, generate arrays

Document.getelementsbyclassname ("a");//classname is not unique, gets all tag objects classname for a array

Document.getelementsbyname ("a");//name property is not unique, gets all tag objects named A, generates arrays

It's the whole label.

After getting the object, you can call the object's innerHTML property if you want to get the contents of the label

Label object. InnerHTML: Represents the text between tags

Label object. InnerHTML = new data: To assign a value to the contents of a label

Bomb frame:

Alert (): a regular window

Confirm (): Pop-up window with a confirmation and cancellation

Prompt (): Popup with Input box

settimeout (func,n)//timer, n seconds after executing the program in Func, the unit is milliseconds

Cleartimeout (s); Cancels the timer effect, and the parameter is the time identification of the settimeout generation

SetInterval (func,n): Perform something at a fixed time interval

Clearinterval (s);

String conversion numeric type parseint ();

var h =document.documentelement.clientheight;//gets a high browser

var w =document.documentelement.clientwidth;//get the browser's width

var div1 = document.getElementById ("id");//Get the object of the label with ID ID

Iw=parseint (W)//Turn W into numerical type

Ih=parseint (h)

div1.style.height=ih+ ' px ';//Assign Value

div1.style.width=iw+ ' px ';

This is the entire content of this article, I hope that you will be in the future in the project to use JavaScript tags and methods to help.

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.