Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript contains tag using a var

  • This topic is empty.
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #40376
    dblader2008
    Member

    I wasn’t sure where to put this under, the site is php, using javascript to change css.

    What I’m trying to do is say if a column contains todays date change its background color, if another column contains todays date change its background color to a different color.
    I’m not at all an expert, it may be as simple as i just don’t know the correct terminology to make it work.

    <script type=”text/javascript”>

    var today = new Date();
    today.setHours(0);
    today.setMinutes(0);
    today.setSeconds(0);
    today.setMiliseconds(0);

    $(document).ready(function() {
    $(‘.start:contains(today)’).css(‘background-color’, ‘#99FF99’);
    $(‘.end:contains(today)’).css(‘background-color’, ‘#F5BCA9’);
    });
    </script>

    #112267
    dblader2008
    Member

    <script type=”text/javascript”>
    $(document).ready(function() {
    var d = new Date();
    var curr_date = d.getDate();
    var curr_month = d.getMonth() + 1; //Months are zero based
    var curr_year = d.getFullYear();
    var today = (curr_month + “/” + curr_date + “/” + curr_year);
    //$(‘.start.contains(‘” + today + “‘)’).css(‘background-color’, ‘#999999’);
    $(“.start:contains(‘” + today.toString() + “‘)”).css(‘background-color’, ‘#99FF99’);
    $(“.end:contains(‘” + today.toString() + “‘)”).css(‘background-color’, ‘#F5BCA9’);
    });
    </script>

Viewing 2 posts - 1 through 2 (of 2 total)
  • The forum ‘JavaScript’ is closed to new topics and replies.