Special characters in a string: In JavaScript, the content of double quotation marks in a double quotation mark string and the content of single quotation marks in a single quotation mark string must be transferred in the following format: varstr1mymothersay: dontspeakwithstranger .; varstr2mymothersay: dontspeakwithstranger .; common in js
Special characters in a string: In JavaScript, the content of double quotation marks in a double quotation mark string and the content of single quotation marks in a single quotation mark string must be transferred in the following format: var str1 = "my mother say: \ "don't speak with stranger \". "; var str2 = 'my mother say:" don \'t speak with stranger ". '; common in js
Special characters in the string:
In js, the content of double quotation marks in double quotation marks and the content of single quotation marks in single quotation marks must be transferred in the following format:
Var str1 = "my mother say: \" don't speak with stranger \".";
Var str2 = 'my mother say: "don \'t speak with stranger ".';
Common escape characters in js include:
"? \"'? \ 'Carriage return? \ R line break? \ Ntab? \ T \? \ Note: The carriage return, line break, space, and tab are also equal to the, B, c, d, and ',', $ & and other symbols.
Date object:
Objects used to represent time and date data. A time and date object contains specific information about time and date, such as year, month, day, hour, minute, second, millisecond, and week.
Defining a time and date object can take the following forms:
D1 = new Date (); // defines a Date object indicating "current time", d2 = new Date ("11:18:19 "); use a string to define a Date object d3 = new Date (2013, 9, 25, 11, 18, 19) for a specified time (time); use multiple (at least 3) number to define a Date object of the specified time d4 = new Date (2324624252312); a number to define a Date object of the specified time.
This number indicates the number of milliseconds that have elapsed since midnight, January 1, January 1, 1970 (or even 0mm. Note: One second equals 1000 milliseconds. -- In fact, we can understand that in Javascript, data such as "time" actually only stores a number. If this value is a negative value, it indicates the previous calculation. In fact, the time can be calculated by addition or subtraction.
This time point is generally regarded as the "time start point/origin point" of the computer world ".
Common methods of time objects:
V1 = d1.toLocaleString (); obtain the "local representation" v1 = d1.getTime (); obtain the "millimeters" of a time-starting from the time origin. The following is a data value in the retrieved time: v1 = d1.getFullYear (); // The number of years obtained. It is a number, and v1 = d1.getMonth () is the same as the number of months. Note: this number starts from 0, that is, it can only be: 0-11 v1 = d1.getDate (); // obtain the number of days v1 = d1.getDay (); // obtain the number of weeks v1 = d1.getHours (); // obtain the number of hours v1 = d1.getMinutes (); // obtain the number of minutes v1 = d1.getSeconds (); // obtain the number of seconds v1 = d1.getMilliseconds (); // obtain the number of milliseconds
The following is a data value in the set time:
D1.setFullYear (n); // set the annual number of copies of the d1 object to n, that is, the year of the object is modified, the same below. D1.setMonth (n); // set the number of months d1. setDate (n); // set the number of days d1. setDay (n); // set the number of weeks d1. setHours (n ); // set the number of hours d1. setMinutes (n); // set the number of minutes d1. setSeconds (n); // set the number of seconds d1. setMilliseconds (n); // set the number of milliseconds
Webpage object Introduction
Var obj1 = {name: "Xiaohua", age: 18, zuofan: functoin (){......}, Xiyi: function (){......}} Var v1 = obj1.age; alert (v1); obj1.age = 19; // a year later, adding one year old -- modified the value of the age attribute of the object obj1. Obj1.name = "Dahua ";
Var obj1 = document. getElementById ("id name ");
Style attributes of the operation object:
Get: var v1 = obj1.style. Style attribute name; -- in fact, this method can only get its "intra-row style"
Value assignment: obj1.style. Style attribute name = a value;
Var obj1 = document. getElementById ("id name ");
Style attributes of the operation object:
Get: var v1 = obj1.style. Style attribute name; -- in fact, this method can only get its "intra-row style"
Value assignment: obj1.style. Style attribute name = a value;
Preliminary event
Simply put, an event is an action, that is, an operation of the user, such as clicking, moving the mouse, double-clicking ,......
First, review and strengthen the "Definition" of js: js is an object-based event-driven scripting language.
Events:
Mouse event: onclick: onmouseover: onmouseout: ondblclick: Double-click event onmousedown: When the mouse is down (note that the mouse is not up yet) onmouseup: onmousemove occurs when the mouse is up: when the mouse moves-the movement is everywhere.
Keyboard event: onkeypress: one click. Onkeydown: onkeyup occurs when the key is pressed down. It occurs when the key is lifted.
Summary: events occur at any time and are everywhere. They are only the objects on which we want to use the events to accomplish what work.
The basic code mode is:
Function f1 () {// here is what we want to do !!!!!} Script
The basic meaning is: when an event occurs for an object, a function is called to complete a task.
Event object
Generally, an event is only used to obtain relevant information when an event occurs. For example, the coordinates (x and y) of the mouse at the moment are used to determine which webpage object has the event, which mouse button is triggered when an event occurs, or which keyboard key is used. The above information is obtained by the following event attributes:
Event. clientX -- obtains the x coordinate position of the mouse when an event occurs.
Event. clientY -- obtains the y coordinate position of the mouse when an event occurs.
Event. keyCode -- key value of the key when a keyboard event occurs -- each key on the keyboard corresponds to a numeric value.
Comparison of this and event: thisevent function f1 (obj) {//} function f2 (evt) {// in this range, evt indicates the event object when an event occurs. // Here, evt is used. Basically, the following attributes are used (as needed): var v1 = evt. clientX; // obtain the x coordinate var v2 = evt at the time of the mouse. clientY; // obtain the y coordinate var v3 = evt at the time of the mouse. keyCode; // obtain the key value of the keyboard (only valid for Keyboard Events) var v4 = evt.tar get; // obtain the event source object, IE is: evt. srcElement;} script