Jquery 如何在mvc中实现图像点击绑定

Jquery 如何在mvc中实现图像点击绑定,jquery,asp.net-mvc,knockout.js,Jquery,Asp.net Mvc,Knockout.js,这是我的简单图像,我想在图像上传递id单击: <img class="pull-right" src="~/assest/image/cross.png" data-bind="attr: { href: unfollowAction }" alt="" /> 请告诉我img tag helper中数据绑定的确切正确语法。请提前告诉我许多THNK。您需要一个Html动作图像 @Html.ActionImage("unfollowAction", new { id = MyId },

这是我的简单图像,我想在图像上传递id单击:

<img class="pull-right" src="~/assest/image/cross.png" data-bind="attr: { href: unfollowAction }" alt="" />

请告诉我img tag helper中数据绑定的确切正确语法。请提前告诉我许多THNK。

您需要一个Html动作图像

@Html.ActionImage("unfollowAction", new { id = MyId }, "~/Content/Images/Image.bmp", "Edit")

有关更多详细信息,请参见此

嗯,您应该尝试以下方法:

self.unfollowAction = location.protocol + "//" + location.host + '/Post/Unfollow?uid=' + data.PostId;
   <a data-bind="attr:{ href: unfollowAction }">
      <img class="pull-right" src="~/assest/images/cross.png" alt="" />
    </a>

如何在此处添加数据绑定属性??