How to access particular cell in gridview using jQuery

You might be knowing that GridView is rendered as table > th > tr > td format. Below jQuery code allows to select first cell or td of every row (tr) in GridView. I have used "eq()" selector to select particular cell.

Also read GridView Tips and Tricks using jQuery

//Code Starts
$(document).ready(function() {
   $("#<%=gdRows.ClientID%> tr:has(td)").each(function() {
      var cell = $(this).find("td:eq(0)");
      alert(cell.html());
   });
});
//Code Ends

With ":eq()" selector you can pass the index of element to select. The ":eq()" selector selects an element with a specific index number. The index numbers start at 0, so the first element will have the index number 0 (not 1). So if you want to select 2nd column then use :eq(1) as the selector.

Feel free to contact me for any help related to jQuery, I will gladly help you.



Responsive Menu
Add more content here...