jquery MVC找到一个隐藏的值

本文关键字:一个 隐藏 MVC jquery | 更新日期: 2023-09-27 18:17:37

我有一个mvc项目。并且我想用jquery. on()点击函数。下面是Razor代码和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工作时,我点击。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找到这个值?谢谢你的回复。

jquery MVC找到一个隐藏的值

我解决了;

下面的代码,

$('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',
        //................................
    });
}

});