Home  >  Article  >  Web Front-end  >  Summary of common JavaScript tags and methods_javascript skills

Summary of common JavaScript tags and methods_javascript skills

WBOY
WBOYOriginal
2016-05-16 15:41:211193browse

What is javascript?

(1) JavaScript is an object- and event-driven scripting language with security features.

(2) JavaScript is a scripting language developed by Netscape. The programs written by it can be embedded into HTML pages and interpreted and executed directly in the browser.

(3) JavaScript can be directly interpreted and executed by the browser, which can better reduce server pressure and improve program operation efficiency.

//Event (event listening):

//Tag object.Event monitoring.function(){Executed code, find object, find attributes, change attributes};

Event source. Trigger an event. Call a method. The method finds the execution code, finds the object, finds the attributes, and changes the attributes (or uses attributes, add, delete, modify, and check)

onmouseover Move the mouse over an element

onmouseout Move the mouse away from an element

onkeydown Press the keyboard (that is, keep pressing it)

onkeypress Press and release the keyboard (that is, click, press and release)

oonkeyup Release the keyboard (that is, when it is released)

onclick Mouse down and then up (click)

onmousedown The mouse button is pressed (hold it down)

onmousemove mouse movement (move with or without pressing)

onmouseout The mouse moves over an element (when the mouse is placed on it)

onmouseup Release the mouse button (when the mouse is released)

onresize The window or frame is resized

window.onresize

onsubmit form submission

onblur The element loses focus

onfocus The element gets focus

The width and height of the blank area of ​​the browser (that is, the width and height of the browser)

Width: document.documentElement.clientWidth;

High:document.documentElement.clientHeight;

//How to get the object:

                        // window.document.getElementById('miao'); // window can be omitted

document.getElementById('miao');//ID is unique and cannot conflict, so what is obtained is an object value, not an array

document.getElementsByTagName("a");//The tag name is not unique. Get all a tag objects and generate an array

document.getElementsByClassName("a");//className is not unique, get all label objects with className a and generate an array

                                                                                   document.getElementsByName("a"); //The Name attribute is not unique, get all the label objects whose Name is a, and generate an array

It’s the entire tag

After obtaining the object, if you want to get the content in the tag, you can call the innerHTML attribute of the object

Label object.innerHTML: represents the text between labels

Label object.innerHTML = new data: assigning values ​​to the content between tags

//Pop-up:

alert(): a normal pop-up window

Confirm(): pops up a confirmation and cancellation pop-up window

prompt(): Pop-up with input box

setTimeout(func,n);//Timer, execute the program in func after n seconds, the unit is milliseconds

                                                                                                                                                                                                                                         

setInterval(func,n): Execute something at a fixed time interval


clearInterval(s);

//String conversion to numeric type parseInt();

var h =document.documentElement.clientHeight;//Get the height of the browser


var w =document.documentElement.clientWidth;//Get the width of the browser


var div1 = document.getElementById("id");//Get the object of the tag whose ID is id


iw=parseInt(w)//Convert w into numeric type


ih=parseInt(h)


div1.style.height=ih 'px';//Assignment


div1.style.width=iw 'px';

The above is the entire content of this article. I hope it will be helpful for everyone to use JavaScript tags and methods when doing projects in the future.

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn