total of row cell not get color red if greatest than 1000
I have 5 column
Name Salary,Bonus,Deduction total
ahmed 500 200 100 600
calculation per total
total=Salary+Bonus-Deduction
if total>1000
make red color per cell total
as sample above i need to get red color per row added
When click button add row must add and total must have red color if greatest than 1000
I try more time to color my cell total only if total greatest than 1000 but not come
my code as following
- @{
- Layout = null;
- }
- <!DOCTYPE html>
- <html>
- <head>
- <meta name="viewport" content="width=device-width" />
- <title>Index</title>
- <script src="~/Scripts/jquery-1.10.2.js"></script>
- <script>
- $(function () {
- $("#btn").click(function () {
- var x = $("#txt1").val();
- var y = $("#txt2").val();
- var z = $("#txt3").val();
- var M = $("#txt4").val();
- var L = parseInt(y) + parseInt(z) - parseInt(M);
-
- $("#tb").append("<tr> <td>" + x + "</td> <td>" + y + "</td> <td>" + z + "<td>" + M + "</td><td>" + L + "</td></tr>");
-
- // $('td').prop('contentEditable', true);
- });
- $("#tb").on("click", "tr", function () {
- if (L > 1000) {
- $(this).parent().prev().addClass('red');
- }
- $(this).find("td").slice(0, 4).prop("contenteditable", true);
- });
-
-
- });
- </script>
- <style>
- .red{
- color:#ff0000;
- font-weight:bold;
- }
- </style>
-
-
- </head>
- <body>
- <div>
- Name<input type="text" id="txt1" /><br />
- Salary<input type="text" id="txt2" /><br />
- Bonus<input type="text" id="txt3" /><br />
- Deduction<input type="text" id="txt4" /><br />
- <input type="button" value="add" id="btn" />
-
- <table>
- <thead>
- <tr>
- <td>
-
- Name
-
-
- </td>
- <td>
-
- Salary
-
-
- </td>
- <td>
-
- Bonus
-
-
- </td>
- <td>
-
- Deduction
-
-
- </td>
- <td>
- total
- </td>
- </tr>
- </thead>
- <tbody id="tb" class="tb1"></tbody>
- </table>
- </div>
- </body>
- </html>