Javascript/jquery Get Row Id on button click in a table -


i beginner in javascript.so trying selected row id on button click.i not sure tried examples on internet not run code.

<tr>  <input type="hidden" name="interestid" id="interestid" value="@info.interestid" />         <th>            <input data-required="true" class="input-sm form-control datepicker" size="16" type="text" name="validdate" id="validdate" value="@info.validdate.toshortdatestring()" />        </th>        <th>            <input class="form-control" data-required="true" name="rate" id="rate" value="@info.rate" />        </th>        <th>            <button type="button" class="btn btn-sm btn-danger" onclick="deleteinterest()">delete</button>        </th> </tr>  function deleteinterest(parameters) {     alert("delete button clicked"); } 

when click "delete" button , want @info.interestid selected row.so how can selected row id on "delete" button click using javascript/jquery ?

any appreciated.

thanks.

use below, ruben said if not passing id function can not directly.

 <button type="button" class="btn btn-sm btn-danger"         onclick="deleteinterest('@info.interestid')">delete</button>   function deleteinterest(id) {    alert("delete button clicked id " + id);  } 

or can below, without change html

 function deleteinterest() {    alert("delete button clicked id " + $("#interestid").val());  } 

Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

Python ctypes access violation with const pointer arguments -