如何执行添加到作为字符串值传递给attr标记的字符串中的html代码?

时间:2018-12-12 07:12:42

标签: javascript jquery html

考虑两个字符串:

name = "Hello"
mess = "Whats up"

现在进入工具提示类,我试图添加一个attr标签,如下所示:

$(this.el).find('.checkcalls').attr('title', "#{name}<br/>#{mess}")

此打印:

"Hello<br/>Whats up"

我不想打印break标签,而是执行它。

我尝试过:

  $(this.el).find('.checkcalls').attr('title', '#{name}<br/>#{mess}')

和:

 $(this.el).find('.checkcalls').attr('title', '"#{name}"<br/>"#{mess}"')

他们没有打印出期望的结果。

我该如何实现?

1 个答案:

答案 0 :(得分:0)

不要使用br-请改用\ n:

JDBC Request

我不知道主干,但是应该可以。

编辑:

找到答案here,这是真的-它是如此简单!只需添加一个实际的按输入键的换行符即可!

$(this.el).find('.checkcalls').attr('title', '"#{name}"\n"#{mess}"');