Get help. Give help. A Web Design and Development Community.

contains tag using a var

  • # October 18, 2012 at 6:45 pm

    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();

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

    # October 18, 2012 at 11:08 pm

    <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’);

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.

We have a pretty good* newsletter.