none
Table dont work at 100% RRS feed

  • Question

  • Hello guys,

    im doing a html page, and i'm getting my live data from zabbix, and in someway i have a condition in php when a number is  x>0.8 that line in the table turns red. it doesnt always turn on. is there a condition in css or something like that to always turn on? because i have a friend he did with a table-responsive and it worked, but i wanted to know if with a simple table can work

    thanks

    Thursday, December 17, 2015 11:50 AM

Answers

  • Hi,disilva1993

    You could use Jquery to change the row's color.

    Please try the following.

    Html

    <table border="1" cellpadding="4" cellspacing="4">
        <tr class="alt">
            <td class="status" value="One">1</div>
            <td class>Received</div>
        </tr>
        <tr class="alt">
            <td class="status" value="One">1</div>
            <td class>Received</div>
        </tr>
        <tr class="alt">
            <td class="status" value="Zero">0</div>
            <td class>Received</div>
        </tr>
        <tr class="alt">
            <td class="status" value="One">1</div>
            <td class>Received</div>
        </tr>
        <tr class="alt">
            <td class="status" value="Zero">0</div>
            <td class>Received</div>
        </tr>
    </table>
    
    

    Jquery

    $(document).ready(function()
    {
    $("tr.alt:even").css("background-color", "#f0f8ff");
    $("tr.alt:odd").css("background-color", "#fcfceb");
    });
    
    $(document).ready(function() {
       $('.status.val():contains("Zero")').closest('tr.alt').css('background-color', '#cd0000');
        $('td.status[value=Zero]').closest('tr').css('background-color', 'red');
    });
    
    
    

    Best regards,

    Chris Zhao

    • Proposed as answer by Pengzhen Song Thursday, January 7, 2016 2:08 AM
    • Marked as answer by Pengzhen Song Thursday, January 7, 2016 2:08 AM
    Monday, December 21, 2015 1:44 AM