简体   繁体   English

将文字插入锚标记html

[英]Insert text into anchor tag html

I have the following code i would like to insert bodytext variable into anchor tag how to achieve this 我有以下代码,我想将bodytext变量插入锚标记中,如何实现此目的

  function blogBodyRenderer(ctx) { var item = ctx.CurrentItem; var html = item['Body']; var plainBodyText = $(html).text(); var res = plainBodyText.substring(0, 15); alert(res); var str2 = 'Read more...'; var bodytext = res.concat(str2); return '<a href="' + ctx.listUrlDir + '/Post.aspx?ID=' + item.ID + '" class="ms-accentText"> + bodytext + </a>'; } 

You are not properly closing the string. 您没有正确关闭字符串。 Try this 尝试这个

'<a href="' + ctx.listUrlDir + '/Post.aspx?ID=' + item.ID + '" class="ms-accentText">' + bodytext + '</a>';

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM