Reputation: 10631
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>');
Upvotes: 4
Views: 21370
Reputation: 48006
You are having issues with your quotes. You wrapped a string with double quotes but then used a double quote in the string therefore terminating the string literal.
Try escaping the internal double quotes (\"
) like this -
'<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>'
Upvotes: 2
Reputation: 61
You should use escaped single quotes for href.
$('#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>');
Upvotes: 0
Reputation: 6864
You need to escape the double quotes that are used in the <a>
href attribute
$('#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>');
Upvotes: 1
Reputation: 6020
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>");
Upvotes: 9
Reputation: 4747
Data in HTML attributes must be htmlentitized, try :
$('#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>');
Upvotes: 1
Reputation: 2997
From :
custom-style="view-more" class="tiply_html_click">1 more');
is wrong...
Upvotes: -2