javascript - Rewrite HTML using jQuery -


i have table looks this:

<table>     <thead>         <tr>             <th>id</th>             <th>link</th>         </tr>     </thead>     <tfoot>         <tr>             <th>id</th>             <th>link</th>         </tr>     </tfoot>     <tbody>         <tr>             <td>1</td>             <td><a href='#' onclick=('remove(0)')>remove</a></td>         </tr>         <tr>             <td>2</td>             <td><a href='#' onclick=('remove(1')>remove</a></td>         </tr>         <tr>             <td>3</td>             <td><a href='#' onclick=('remove(2)')>remove</a></td>         </tr>         <tr>             <td>4</td>             <td><a href='#' onclick=('remove(3)')>remove</a></td>         </tr>         <tr>             <td>5</td>             <td><a href='#' onclick=('remove(4)')>remove</a></td>         </tr>         <tr>             <td>6</td>             <td><a href='#' onclick=('remove(5)')>remove</a></td>         </tr>     </tbody> </table> 

where inparameter remove() rownumber. in remove function i'm removing row, means need rewrite rownumbers if want delete more once before reloading page. how can achieve using jquery?

remove onclick rows , use jquery. there no need rewrite then.

$(document).on("click", "a.remove", function() {      $(this).closest("tr").remove();  });
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>  <table>    <tr>      <td>1</td>      <td><a class="remove" href='#'>remove</a></td>    </tr>    <tr>      <td>2</td>      <td><a class="remove" href='#'>remove</a></td>    </tr>    <tr>      <td>3</td>      <td><a class="remove" href='#'>remove</a></td>    </tr>  </table>


Comments

Popular posts from this blog

magento2 - Magento 2 admin grid add filter to collection -

Android volley - avoid multiple requests of the same kind to the server? -

Combining PHP Registration and Login into one class with multiple functions in one PHP file -