I have this table that is loaded from the database, so all the elements from each row have the same attributes.
<table class="table table-responsive"> <tr> <th>Product name</th> <th>Quantity</th> <th>Price per unit</th> <th>Total</th> <th>Action</th> </tr> <tr> <td class="product-name">Product one name</td> <td class="product-quantity"> <button class="btn"> +</button> <input type="text" value="2"/> <button class="btn"> -</button> </td> <td class="unit-price">50</td> <td class="total-price">100</td> <td> <button class="product-delete">Delete</button> </td> </tr> ... </table> <div class="grand-total"> 5000 </div>
I tried to make jQuery , but could not handle it, since each row has the same attributes. I cannot select a specific row and update its contents to make this work.
I searched a lot, but all I found was HTML manipulation based on id and class selector, which I cannot use, since the elements from each row have the same class, and I cannot give a unique identifier to each element because they are loaded from the database (PHP).
I would really appreciate it if someone could tell me how to do this in jQuery . And please don't give me links to static HTML manipulation using jQuery I want a solution for dynamic HTML elements .
source share