Get id of selected row in a table -HTML

后端 未结 2 550
挽巷
挽巷 2020-12-06 03:36

I have a table in my MVC application.I want to get the id of the selected row.I captured the click event of tr using jQuery. The table sample is shown below



        
2条回答
  •  庸人自扰
    2020-12-06 04:01

    $(document).ready(function () {      
         $('#resultTable tr').click(function (event) {
              alert($(this).attr('id')); //trying to alert id of the clicked row          
    
         });
     });
    

提交回复
热议问题