1

I am working on ASP.NET MVC3 application. In my razor view I use @HTML.ActionLink to implement delete functionality for my custom image gallery. However when I show enlarged image I want to hide this link, and when the user clicks it back to thumb size I want to show the link again.

Here is my razor code:

<span class="document-image-frame">
        @if (image != null)
        { 
            <img src="file:\\105.3.2.7\upload\@image.Name" alt="docImg" style="cursor: pointer;" />
            @Html.ActionLink("Изтрий", "DeletePicture", new { documentImageID = image.Id }, new { @class = "delete" })
        }
        </span>

Then my jQuery script:

$('.document-image-frame img').click(function () {
    $(this).parent().toggleClass("document-image-frame");
    //$(this).parent().child('a').hide();
})  

This part - $(this).parent().toggleClass("document-image-frame"); is working fine but I don't know how to access the actionlink in order to show-hide it.

4

1 回答 1

2

你可以find这样链接:

$(this).parent().find("a.delete").show(); // or .hide()

我还喜欢使用该类来指定要删除的链接,以防您将来可能想添加其他链接并且希望它们的行为有所不同...

于 2013-06-10T11:00:47.360 回答