在javascript中将链接更改为按钮

时间:2015-11-13 16:12:47

标签: javascript jquery

我的功能是正确显示链接,但我希望它显示为一个按钮。我尝试使用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>

0 个答案:

没有答案