JavaScript dynamically changes the state behavior of elements in the current page

Source: Internet
Author: User

function Datea () {


var timed = document.getElementById (' timed ');
var t = setinterval (function tdate () {
var D1 = new Date ()
var h = d1.gethours ();
var m = d1.getminutes ()
var s = d1.getseconds ()
To determine if h,m,s is less than 10
H1 = h < 10? ' 0 ' + h:h
M1 = M < 10? ' 0 ' + m:m
S1 = s < 10? ' 0 ' + s:s
var str = h1 + ': ' + m1 + ': ' + S1;
Console.log (str)
if (str >= ' 00:00:00 ' && str < "12:00:00") {
timed.innerhtml = ' Good Morning '
Return
} else if (str >= "12:00:00" && str < "18:00:00") {
timed.innerhtml = ' Good afternoon '
Return
} else if (str >= "18:00:00" && str < "24:00:00") {
timed.innerhtml = ' Good evening '
Return
}

}, 1000)
}
Datea ();

JavaScript dynamically changes the state behavior of elements in the current page

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.