You only need to avoid single quotes
var content = '<a href="#" onclick="displayContent(\'TEST\')">Whatever</a>'
As bozdoz says:
You avoid single quotes that are in single quotes; you avoid double quotes that are enclosed in double quotes
But why not do
var content = $("<a />").attr("href", "#").text("Whatever").click(function(){ displayContent('TEST') });
Or, as Nathan says:
var content = $('<a href="#">Whatever</a>').click( function() { displayContent('TEST') });
source share