我有一個表格,有3列。最後一列是鏈接,當我點擊該鏈接時,我需要將特定行的值顯示爲警報。在Jquery Alert中顯示錶格行的所有值
<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
});
});
你錯過了職業 – Liam 2013-02-27 15:35:12
我加了,也並不重要,他可以添加它自己,這樣的邏輯後... – 2013-02-27 15:36:38
啊,我知道,只是想幫助:) – Liam 2013-02-27 15:37:06