javascript - Get the row index of bootstrap table in click without using jquery -


i have bootstrap table in react project. want index of row click on. want onclick = {this.handleclick} , in handleclick function want index of row. possible it. of solutions available shows using jquery , don't want use jquery. want using javascript only. table

<table classname='flags-table' responsive hover>                                     <thead>                                         <tr>                                             <th> </th>                                             <th> time in </th>                                             <th> time out </th>                                             <th> type </th>                                             <th> category </th>                                         </tr>                                     </thead>                                     <tbody>                                         {                                             flags_list.map((x,i)=> (                                                 <tr key={i}>                                                     <td> <div classname='red-box'></div> </td>                                                     <td> {x.time_in} </td>                                                     <td> {x.time_out} </td>                                                     <td> {x.type} </td>                                                     <td> {x.category} </td>                                                 </tr>                                             ))                                           }                                     </tbody>                                 </table> 

you can use code this:

onclick = {this.handleclick.bind(this, i)};  

and handleclick should declare this:

var handleclick = function(i) { console.log("key of row", i) ... }; 

Comments

Popular posts from this blog

python - How to insert QWidgets in the middle of a Layout? -

python - serve multiple gunicorn django instances under nginx ubuntu -

module - Prestashop displayPaymentReturn hook url -