Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

how to use moment to compare time for calendar change color

var checkTime = function () {
    var hour = $(".hour").text().trim();

    var time = moment(hour, "LT");
    console.log(time)

    //remove any old classes from element
    $(".hour").removeClass(".present .past .future");

    // apply new class if task is near/over due date
    if (moment().isAfter(time)) {
        $(".hour").addClass(".past");
    } else if (moment().isBefore(time)) {
        $(".hour").addClass(".future");
    } else {
        $(".hour").addClass(".present");
    }
}

checkTime();
Comment

PREVIOUS NEXT
Code Example
Javascript :: python dictionary setdefault in javascript 
Javascript :: Custom delay function for waitfor puppeteer 
Javascript :: calcular sobra de divisão de parcelas js 
Javascript :: javascript modify href attr 
Javascript :: call dynamic var name javascript 
Javascript :: iteration through json with key value pairs 
Javascript :: react js require pasword to have special charaacter 
Javascript :: check whether array ascending 
Javascript :: dayofmonth mongodb 
Javascript :: textarea events react testing library 
Javascript :: .tolowercase 
Javascript :: angular cli spec test false 
Javascript :: react useState update object in array of objects 
Javascript :: react form hook trigger is not a function 
Javascript :: shallow render in react 
Javascript :: js regex word before word 
Javascript :: contact form angular material 
Javascript :: time zone browser javascript 
Javascript :: browser.find_element_by_ <a 
Javascript :: mongoose get elements that contain substring 
Javascript :: react fun tion 
Javascript :: angular router navigate inside setTimeout 
Javascript :: formdata 
Javascript :: how to detect input value change by javascript observe 
Javascript :: javascript append list to list 
Javascript :: update karma jasmine to specific version 
Javascript :: javascript sort multi-dimensional array by column 
Javascript :: setinterval 
Javascript :: react-particles-js not working 
Javascript :: svg clientx 
ADD CONTENT
Topic
Content
Source link
Name
3+8 =