Running into an issue. In running the code below, I'm trying to replace a string of text that appears in an blog excerpt field with a clickable link.
jQuery(document).ready(function( $ ) {
var elements = document.getElementsByClassName('post-excerpt');
if (elements.length > 0) {
$('.post-excerpt').html($('.post-excerpt').html().replace(/((http:|https:)[^\s]+[\w])/g,'<a href="$1" target="_blank">$1</a>'));
}
});
The problem is that the link from the first except is being copied to all other buttons on the page. How do I modify the code above to make sure that it parses through each excerpt link UNIQUELY and replaces that string with an equivalent HTML link?
