jquery - Get button value in click inside HTML table -


i create grid in c# mvc 3. , place delete button in every rows in grid.

please see image below.

enter image description here

delete button code.

<td>  <button id="removefromcart" type="button" name="removefromcart"            class="remove-cartitem" value="@(item.id)"> </button></td> 

script :

<script type="text/javascript"> $(document).ready(function () {      $('[name="removefromcart"]').click(function () {         alert('clicked');     });  }) 

i try alert value of clicked button.

please help

use class attribute of dom element

<script type="text/javascript"> $(document).ready(function () {  $('.remove-cartitem').click(function () {     alert($(this).val()); });  }); </script> 

Comments

Popular posts from this blog

node.js - Bad Request - node js ajax post -

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -