i want to put a link "Read more" in a div 'guest-message' when the number of characters is more then 300.
In the link are some php variables:
<a href="?data=<?php echo $database; ?>&guest=<?php echo $item[3]; ?>" title="permalink" class="permalink">Read more</a>
The jquery function:
$(".guest-message").each(function () {
len=$(this).text().length;
str= $(this).text().substr(0,300);
lastIndexOf = str.lastIndexOf(" ");
if(len>300) {
$(this).text(str.substr(0, lastIndexOf) + '...Read more');
}
});
});
So: how can i put the link in the js on the place where now is '...Read more' ?