我有表:ASP.NET MVC的JQuery最接近HiddenFor VAL
<table class="table table-bordered">
@for (var i = 0; i < Model.Count; i++)
{
<tr>
<td width="25px">
@if (!Model[i].Letter.Equals(letter))
{
@Html.DisplayTextFor(m => Model[i].Letter);
}
</td>
<td width="45px">
<div class="button-edit"></div>
</td>
<td>
@Html.HiddenFor(m => Model[i].Student.Id, new { @class = "mojaklasa" })
</td>
<td>
...
</td>
<td>
...
</td>
<td>
...
</td>
</tr>
}
</table>
,我怎麼能得到最接近hiddenfor值按鈕? 我想:
$(document).ready(function() {
$('.button-edit').each(function() {
$(this).mouseenter(function() {
$(this).fadeTo(20, 1).css('cursor', 'pointer');
});
$(this).mouseleave(function() {
$(this).fadeTo(20, 0.5);
});
$(this).click(function() {
var id;
$(this).closest('.mojaklasa').val(id);
alert(id);
});
});
,並用$(本)。接下來.... 不過如果我點擊這個按鈕,我沒有在警告框東西。 我甚至把類放進去,但我可以從中得到這個文本。