01.Javascript several output modes
Document.wrte (); Document Print output
Console.log (); Console output
Console.warn (); Console Alerts
Console.error (); Console error prompt
Alert (); pop-up windows, rarely used, poor user experience
02. Three elements of the event
Event Source Event Event Handler
Event source. Event =function () {event handler};
Common event Description
- OnClick Mouse click
- OnDblClick Mouse Double-click
- onkeyup triggers when a key of the keyboard is pressed and released
- OnChange the options in the text content or drop-down menu change
- Onfocus gets focus, indicates text box, etc. get mouse cursor
- Onblur loses focus, indicates that the text box loses the mouse cursor
- onmouseover mouse hover, that is, the mouse over the picture, etc.
- onmouseout mouse removal, that is, to leave the image and other areas
- OnLoad Web page document Load event
- OnUnload when you close a webpage
- OnSubmit Form Submission Events
- OnReset when resetting the form
03. Hide Style
Display:none Display:block; The meaning of the display
Visibility:hidden; Visibility:visible the meaning of the display
Display Hide not occupying position
Visibility:hidden hide occupy position suspended pay attention
Overflow:hidden; Hide the excess part
04 images have been switched
var Pic=document.getelementbyid ("pic");
Pic.onmouseover=function () {
Pic.src= "Images/02.jpg";
}
Pic.onmouseout=function () {
Pic.src= "Images/01.jpg"; Style is added style,src is a property, do not need
}
The writing position of 04.js
1.
in-line
<button onclick= "alert (' Hello ')" > click me </button>
2. Built-in
<script type= "Text/javascript" > </script>//Anywhere
3. External-linked
<script type= "Text/javascript" src= "xx.js" ></script>//There's nothing inside.
Data type
Js data types are divided into:
Character-type numeric Boolean type null undefined
Js is a kind of weak data type.
Var Aa = 10;
Var aa:int = 10;
Js variable you give what value, he is what data type.
Character type (string)
String
Convert to Character type:
1. Use "" (double quotes)
The quotes are all character types.
2. Using string (); Convert to Character type
Boolean Type (Boolean)
True and false for two values right and wrong
The data type is converted to a Boolean type:
1. Use!!
console. log (typeof!!) NUM);
2. Using the Boolean ()
False, undefined, null, 0, "" is false
True, 1, "somestring", "[Object] is true"
Numeric type
Var num = 10
A value preceded by 0 indicates octal
Var num = 020;
0*80+2*81 = 16
Value preceded by 0x for hexadecimal
var result = 0xb; 11
Convert to Numeric type:
1. Use-*/both can be converted
2 Using number ()
parseint () parsefloat ()
parseint (value, binary);
parseint (110,2)
Represents 2 binary Bar 10 This 2 binary conversion to 10 binary
0*20+1*21 + 1*22 = 6
1.var a= "15.15abc", b= ' 10.15 ', c= ' 10.0abc ';
Alert (parseint (a) +number (b) +parsefloat (c));
Null undefined
Null empty has no value.
Undefined undefined should have a value, but not given.
Null ""
Basic JavaScript knowledge