我的功能是正确显示链接,但我希望它显示为一个按钮。我尝试使用addClass(),如下所示,但它仍然只显示为链接:
var attachUrlHtml = groupPlay.AttachmentFileName.link(groupPlay.AttachmentUrl);
$('@Html.IdFor(model => model.GroupPlayInput.Attachment)').addClass("btn btn-default");
var attachUrl = document.getElementById('@Html.IdFor(model => model.GroupPlayInput.Attachment)');
attachUrl.innerHTML = attachUrlHtml;
编辑:忘记显示它引用的div:
<div style="padding-top: 5px;" id="@Html.IdFor(view => view.GroupPlayInput.Attachment)">
@if (Model.GroupPlayInput.Attachment.IsNotNull())
{
<a href="@Model.GroupPlayInput.Attachment.Url" target="_blank">@Model.GroupPlayInput.Attachment.Url</a>
}
</div>