Within my View, I am displaying data using a table.
Below is the code snippet:
@foreach (var item in Model)
{
<tr >
// Table row content here...
</tr>
}
I have buttons with unique identifiers, such as id="send"
, and I need to extract the associated email value using JavaScript. The challenge arises when there are multiple rows with corresponding buttons.
How can I efficiently retrieve the specific email value via JS?
UPDATE
Here is a segment of the page's source code:
<div class="container body-content">
// Additional HTML markup...
<table class="table">
// Table content here...
</table>
<script type="text/javascript">
function grabEmail(element) {
var email = $(element).data('email');
alert(email);
}
</script>
</div>