Operating element - a String object - the object -Array date objects (array) -math Starts Object - Timer

--- Looking element
by id find html element
var nv = document.getElementById ( "id name") .innerHTML = "change the content";
find html elements by tag name
document.getElementByTagName ( "tag name") // same elements first

--- by changing the CSS DOM object
syntax: document.getElementById (the above mentioned id) .style.property = new new style
. Document.getElementById ( "div") style.background = "Red";


--- event handler EventListener
document.getElementById (the above mentioned id) .addEventListener ( "the Click", the Hello function);


--- string object
lookup string string: indexOf ()
Content Match: match ()
Replace Content: replace ()
to change case: toUpperCase () / toLowerCase ()
String switch array: var str = "hello like hah "- can also be separated by commas
var s = str.split (" ")


--- date object
current date
var data = new Date ();
Get Year
the getFullYear ();
the getTime (); Get milliseconds
getDay (); Get week
the setFullYear (); set a specific date

Minutes acquiring
function the startTime () {
var = new new Today a Date ();
var today.getHours H = ();
var today.getMinutes m = ();
var today.getSeconds S = ();
m = checktime (m);
checktime = S (S);
document.getElementById ( "timetext") the innerHTML = S + H + m;.
calls itself
refresh
T = the setTimeout (function () {
STARTIME ();
}, 1000);
}
prevent change in length
plus Analyzing a
function checktime (I) {
IF (I <10) {
I = "0" + I;
}
return I;
}


------ Array Objects
1. separate series of variable names to store the value
created array 2.
Examples: var myArray = [ "Hello"
access array 3 :
by specifying the array name and index number, you can access a particular element.
Note: [0] is the first element of the array. [1] is the second element of the array
4. The array of commonly used methods:
the concat (); merge array
Sort (); sort
Push (); append array
Reverse (); inverted array elements

----- the Math Object
1.Math objects:
to perform common tasks arithmetic
2. Method used:
round (); rounded
Random (); returns a random number between 0-1
max (); return the highest value
min () ; returns the lowest value
ABS (); returns the absolute value
Math.max (10,20,1);


---- DOM HTML object control
method
getElementsByName (); Gets name
getElementsByTagName (); Gets the element
getAttribute (); Gets the element attributes ---
setAttribute (); access settings element attributes --- setAttribute ( "Properties", "assignment ")
childNodes (); access to the child node
parentNode (); access to the parent node
createElement (); creates an element node
createTextNode; create a text node
insertBefore (); insert node
removeChild (); delete nodes
offsetHeight; page size - the height of wide high
scrollHeight ; page size - include scroll bars

---- js browser object
1.window objects
global variables are properties of the window object of
global function is the window object method
internal height wondow.innerHeight- browser window
window.open () - opens a new window
window.close () - Close the current window
2. timer
timed events: by using js, we have the ability to do yo at a set time interval
of the later code execution. Not performed immediately after the function is called;
--setlnterval (); interval specified number of milliseconds to execute specified code kept
clearlnterval (); a method for stopping the function code setlnterval () method performed
--setTimeout (); performing specified number of milliseconds after the pause specified code
the clearTimeout (); performing a method for stopping
var = MyTime the setInterval (function () {
the getTime (); // call performed once every 1 second
}, 1000);
function the getTime () {
var new new D = a Date ();
var d.toLocaTimeString = T (); Get minutes and seconds
document.getElementById ( "the ptime") the innerHTML = T;.
}

Suspended -
function stopTime () {
the clearInterval (MyTime);
}

3.History objects
window.history object contains the browser's history (url) collection
history.back () - and the same in the browser click the Back button
history.forward () - and click the button in the browser forward the same
history. go () - into the history of a page
4.Location objects

Screen Object
Navigator objects
pop-up window
Cookies
History objects
back to the previous page,
history.back (); and in the same browser click the Back button
history.go (-1); entering a page in the history of
history.forword ();

Location object
used to get the address of the current page, and the browser is redirected to a new page
Screen object
width screen.availWidth-- available screens
screen.availHeight-- available screen height
screen.Height- screen height

Guess you like

Origin www.cnblogs.com/fdxjava/p/11299042.html