Trying to simplify a task, but I'm struggling with the solution. What I want to achieve is shortening a link to 30 characters and adding ... at the end if it's longer. Also, I'd like to make it possible to see the full link on hover similar to Amazon.
https://i.sstatic.net/iIMZh.png
Here's my current function that isn't working as intended:
function shortenLink() {
var string = $("div a").text();
if (string.length > 30) {
string.substring(0, 30);
string.append('...')
}
}