Home > Article > Web Front-end > Summary of common JavaScript tags and methods_javascript skills
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
//String conversion to numeric type parseInt();
var h =document.documentElement.clientHeight;//Get the height of the browser
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.