Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Appending the html with quotes in JQuery

Tags:

jquery

I'm appending some HTML tags when a user clicks on "like" in feeds section of my website. But it is breaking. I tried with lot of solutions available on the web, but I could not find the solution.

Here is the code I'm using:

$('#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>');
like image 312
Stranger Avatar asked Jan 16 '23 20:01

Stranger


1 Answers

You need to escape your quotes, try this 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>");

like image 148
Paul Aldred-Bann Avatar answered Jan 18 '23 10:01

Paul Aldred-Bann