[英]issues replacing html with link JavaScript
I'm trying to make a text into a link in my Javascript code. 我正在尝试将文本变成Javascript代码中的链接。 This should work but it doesn't.
这应该可以,但是不能。
var strLink = <a href="xxx" style= "text-decoration:none; color:#fff;">"mysite.com" </a>;
var cb_header = chatbox.find('.imjs-header');
cb_header.html(cb_header.html().replace('{username}', strLink));
I have a variable called username and it is a string. 我有一个名为username的变量,它是一个字符串。 That is the string that used to replace {username}.
这是用于替换{username}的字符串。 Maybe I can use jquery?
也许我可以使用jQuery? I can't seem to get it a link though.
我似乎无法获得链接。 Any pointers in the right direction are greatly appreciated.
任何朝着正确方向的指针都将不胜感激。
Thank you, Arjun 谢谢阿俊
var strLink = '<a href="xxx" style= "text-decoration:none; color:#fff;">"mysite.com" </a>'
;
尝试这个:
var strLink = '<a href="xxx" style= "text-decoration:none; color:#fff;">"mysite.com" </a>';
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.