How would I sanitize this string? (preferably in JQuery)?
If you want to display it in an element, you can use the text
method. It will escape all the HTML for you.
You can see an example here.
<input type="text" onkeyup="$('#outputDiv').text($(this).val());" />
<div id="outputDiv"></div>
$('div.whatever').text($('input.whatever').val());
That'll convert things to HTML entities, so they're displayed as they were typed, and not treated as markup.