Front-end basic-javascript fifth day

Source: Internet
Author: User

Set node propertiesGet Node Properties

GetAttribute ( property ) Get Property

by this method, you can get  of some elements Some properties

Set node properties

SetAttribute ("attribute", "value");

For example, we want to put a  class name Change to Demo

Div.setattribute ("Class", "Demo");

Delete a property

RemoveAttribute ("attribute");

Demo.removeattribute ("title")

this box has no title attribute to delete.

Date Function(Date ())Declaration Date

var date = new Date ();

Using functions

Get Number of milliseconds

from 1970 year 1 months , number 1

var date = new Date ();

Date.gettime ();

Date.valueof (); Get the distance 1970 number of milliseconds in the year

methods of the usual dates

GetDate () get day 1-31

GetDay () Get week 0-6

GetMonth () get month 0-11

getFullYear () Get the full year (browser supported)

GetHours () Get hours 0-23

getminutes () Get minutes 0-59

Getseconds () get seconds 0-59

Getmilliseconds () gets the current millisecond

GetTime () returns the cumulative number of milliseconds ( from 1970/1/1 midnight )

Timer

Common wording

Countdown

Countdown = Use the future time - the current time

Questions: in milliseconds minus now distance 1970 Year 1

Future Time Distance 1970 milliseconds

with the number of milliseconds in the future- the current number of milliseconds will be converted.

Define your own days.

var endTime = new Date ("2015/12/12");

if the date in parentheses is the time of your own definition

if no date is written in the date parenthesis, it is the current time.

date and time seconds between separated by a space

1. node pages are composed of a number of nodes.

element Node refers to : label Li Span

text Node attribute Node

Brother and son Father ParentNode nextSibling

child childNodes NodeType = = 1 To determine if it is an element node

<ul>

<li>

favorite Children only get the element node

1. Get node Properties getattribute("title")

2. Set node Properties SetAttribute ("class", "one")

3. Delete node attribute removeattribute ("title");

4. Date function Dates ();

Disclaimer : var date = new Date ();

use : get the current year date.getfullyear ();

month : Date.getmonth ();

days ; Date.getdate ();

Week: date.getday ();

5. Timers

Timer   No manual action required take some action at a certain time.

SetInterval ("function", interval ) executes function once every n seconds

Front-end basic-javascript fifth day

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.