Trouble with .before jQuery

I have a very simpel jQuery function where i want to pass the link string containg an url to a span containing a class called .post-link

But the whole string of link is not being passed before .post-link.
Can anybody please tell me why. According to jQuery library i should be able to pass html with .before()

The link is being copyed from a span

<span class="post-link">some link</span>

$('.postContainer').each(function(i) {
	var link = '<a href="' + $(this).find('.post-link').text() + '">';
	  $(this).find('.headline').before(link);
	  $(this).find('.post-link').before('</a>');
});


It’s the context of what it’s being placed before which is causing the trouble.
‘</a>’ is not a valid reference to an element in the DOM, so nothing can be placed before it.