How to get elements in JS
To get an element by an ID name:
document.getElementById (' ID of element ')
Events: Mouse events, keyboard events, system events, form events, custom events ....
OnClick//Click events
onmouseover//mouse move in
onmouseout//Mouse away
ONMOUSEDWN//Press to show something later
OnMouseUp///mouse raised an event
OnMouseMove//Stroke events
How to add an event:
element. onmouseover
Function: Can be understood as-command, do something
Function name () {//Definitely not active!
Document get element by id ' link '
Docuemnt.getelementbyid (' link ');
}
1, Direct call: Name ();
2. Event invocation: element. event = function name Odiv.onclivk= name;
function () {} anonymous functions
element. event = function () {};
Test: Alert (1); A warning box with a OK button
Alert ('); String double quotes are also possible, as long as the pairing appears
Variable:
var li = document.getElementById (' lis ');
var num = 123;
var name = ' Leo ';
Learn JS Basics (1)