我有一个mvc项目。并且我想.on()用jquery点击功能。下面是剃刀代码和js代码,
<div class="cart-info">
<table class="table table-striped table-bordered">
<tr>
<th class="name">Adres Tanımı</th>
<th class="model">Adresim</th>
<th class="quantity">Şehir</th>
<th class="price">Aktifliği</th>
<th class="total">İşlemler</th>
</tr>
@if (Model.Addresses.Any())
{
foreach (var item in Model.Addresses)
{
<tr>
<td class="name"><a href="#">@item.AddressName</a></td>
<td class="model">@item.AddressLine1 @item.AddressLine2</td>
<td class="quantity">@item.City </td>
@{
var result = item.AddressStatus == true ? "Aktif" : "Pasif";
}
<td class="price">@result</td>
<td class="total"><a href="" class="update-address"><img class="tooltip-test" data-original-title="Değiştir" src="@Url.Content("~/Content/img/update.png")" alt="Değiştir"><input type="hidden" class="find-me" value="@item.AddressID"/></a>
<a href="" id="delete-address"><img class="tooltip-test" data-original-title="Sil" src="@Url.Content("~/Content/img/remove.png")" alt="Sil"></a></td>
</tr>
}
}
else
{
<tr><td colspan="5"> Kayıtlı Adres Bulunamadı</td></tr>
}
</table>
</div>
js work当我点击.update-address。代码如下,
$('.update-address').on({
click:function(event) {
event.preventDefault();
var message = ???????;//
$.ajax({
url:'Account/GetAddress',
type: 'GET',
data: message,
contentType: 'application/json; charset=utf-8',
dataType: 'json',
//................................
});
}
});
但是我找不到.find-me的价值。如何用jquery找到这个值?谢谢你的答复。
答案 0 :(得分:0)
我解决了;
代码如下,
$('td.total a.update-address').on({
click:function(event) {
event.preventDefault();
var message = $(this).find('.find-me').val();
$.ajax({
url:'Account/GetAddress',
type: 'GET',
data: message,
contentType: 'application/json; charset=utf-8',
dataType: 'json',
//................................
});
}
});