This is my HTML in display template. How can I assign value to href in javascript?

<span class="AnchorCls">
  <a id="link" href="#">_#=readMore=#_</a>

href should be like this:

 "/sites/Pages/BlogDetail.aspx?ID='" +newID + "'"

In the display template make the following change:

var listItemID = ctx.CurrentItem.ListItemID;  //change as per your ID
var blogUrl = "/sites/Pages/BlogDetail.aspx?ID=";
var viewBlogUrl = blogUrl + listItemID;

HTML would be as below:

<a href="_#= viewBlogUrl =#_" target="_blank">Blog Title</a>
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.