3列のテーブルがあります。最後の列は、そのリンクをクリックしたときのリンクです。特定の行の値をアラートとして表示する必要があります。
<table border="1">
<tr>
<th>
id
</th>
<th>
name
</th>
<th>
Occupation
</th>
<th>
click the link
</th>
</tr>
@foreach (var i in Model.allHuman)
{
<tr>
<td>
@Html.DisplayFor(mo => i.id)
</td>
<td>
@Html.DisplayFor(mo => i.name)
</td>
<td>
@Html.DisplayFor(mo => i.occupation)
</td>
<td>
<a href='' id='ppl' name='ppl' class='humanclass'> display </a>
</td>
ユーザーがリンクをクリックすると、その特定の行の内容を含むアラートが表示されます。コンテンツは、とID
が後に続く形式である必要がNAME
ありますOCCUPATION
。
JQuery メソッド:
$(function () {
$('.humanclass').click(function () {
alert( ?????????? ); // How to display ID, NAME and OCCUPATION of the ROW
});
});