-3

please suggest me my code :

$('.Create-New-Order').click(function () {
    var totalRowCount = $("#table_New_Order tbody tr").length;
    alert(totalRowCount);
});

enter image description here

Carsten Løvbo Andersen
  • 26,637
  • 10
  • 47
  • 77
  • Possible duplicate of [jQuery: count number of rows in a table](http://stackoverflow.com/questions/1149958/jquery-count-number-of-rows-in-a-table) – Sorangwala Abbasali Jan 31 '17 at 07:30
  • 2
    Assuming you've included jQuery in the page properly and are running your code when the DOM has loaded, what you have should work. Given that you're trying to use the content of a modal window, I'd guess you need a delegated event handler for the `#Create-New-Order` button – Rory McCrossan Jan 31 '17 at 07:31
  • 1
    Put your HTML please – Alessandro Jan 31 '17 at 07:31
  • Once check console if there is any error message, if yes then post here – Rahul Jan 31 '17 at 07:31

1 Answers1

1

On-load table tr count

$(function() {
  $('.Create-New-Order').click(function() {
  var total = $('#mytbl tr').length ;
  alert('tr count = '+ total);
  });
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>

<table border="1px solid red">
 <tr>
   <th>Name</th><th>Email</th>
 </tr>
 <tbody id="mytbl">
 <tr>
   <td>sfdsd</td><td>tsdaf@ymail.com</td>
 </tr>
  <tr>
   <td>sfdsd</td><td>tsdaf@ymail.com</td>
 </tr>
  <tr>
   <td>sfdsd</td><td>tsdaf@ymail.com</td>
 </tr>
 </tbody>
</table>
<br>
<br>
<a href="#" class="Create-New-Order">Create-New-Order</a>
Aman Kumar
  • 4,533
  • 3
  • 18
  • 40