Advertisement
IamMarble

tính toán

Mar 21st, 2018
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
jQuery 1.33 KB | None | 0 0
  1. .
  2. .
  3. .
  4. <script type="text/javascript">
  5. $(document).ready(function(){
  6.    
  7.    $(".add-row").click(function(){
  8.      
  9.       var name = $("#name").val();
  10.       var classn = $("#classn").val();
  11.       var maths = $("#maths").val();
  12.       var physic = $("#physic").val();
  13.       var chemist = $("#chemist").val();
  14.       var add = '<tr> <td></td> <td>' + name + '</td> <td>' + classn + '</td> <td>' + maths + '</td> <td>' + physic + '</td> <td>' + chemist + '</td> <td><p class="tb">?</p></td> </tr>';
  15.       $("tbody").append(add);
  16.    });
  17.  
  18.    $(".countTB").click(function(){
  19.          
  20.       var x = $("#maths").val();
  21.       var y = $("#physic").val();
  22.       var z = $("#chemist").val();
  23.       var average = (x+y+z)/3;              //khi x, y, z = 1 thì average lại cho đáp án 37
  24.       $("p").each(function(){
  25.          if ($(this).html() == "?") {
  26.             $(this).html('');
  27.             $(this).append(average);
  28.          };
  29.       });
  30.    });
  31.  
  32.    $(".countHSG").click(function(){
  33.                                                                                                                
  34.       $("tr p").each(function(){
  35.          if ($(this).html() !=="?" && $(this).html() >= 8) {
  36.             $(this).css("color", "red");    //chỉ tô đỏ p thôi, yêu cầu là tô đỏ nguyên hàng
  37.          };
  38.       });
  39.    });
  40. });
  41. </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement