在JQuery中添加带引号的html

Str*_*ger 1 jquery

当用户点击我网站的Feed部分中的"like"时,我会添加一些HTML标记.但它正在打破.我尝试了网上提供的大量解决方案,但我找不到解决方案.

这是我正在使用的代码:

$('#feed20').find('strong')
.append('<span original-title="<ul><li>
<a href="http://localhost/forex/profile/username">username</a>
</li></ul>" custom-style="view-more" class="tiply_html_click">1 more</span>');
Run Code Online (Sandbox Code Playgroud)

Pau*_*ann 6

你需要逃避你的报价,试试这个jsFiddle

$("#feed20").find("strong").append("<span original-title=\"<ul><li><a href='http://localhost/forex/profile/username'>username</a></li></ul>\" custom-style=\"view-more\" class=\"tiply_html_click\">1 more</span>");
Run Code Online (Sandbox Code Playgroud)