Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
<!DOCTYPE html>
<html>
<head>
<script class="jsbin" src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<meta charset=utf-8 />
<title>JS Bin</title>
<!--[if IE]>
  <script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<style>
table {
    width: 150px;
}
</style>
</head>
<body>
  
<table border="1">
    <tr><td>Test 1</td><td>8.1</td><td>-3.8</td></tr>
    <tr><td>Test 2</td><td>-2.6</td><td>5</td></tr>
    <tr><td>Test 3</td><td>8</td><td>3.4</td></tr>
</table>
 <script>
// for each table cell
$('td').each(function() {
    // get table cell value and try to convert to an float
    var fValue = parseFloat($(this).text());
    // if value is a number and less then zero
    if (!isNaN(fValue) && fValue > 8) {
        // change the background color to red
        $(this).css('background-color', 'red');
    }
});
</script>
  
</body>
</html>
Output

You can jump to the latest bin by adding /latest to your URL

Dismiss x
public
Bin info
anonymouspro
0viewers