The following code is supposed to surround the highlighted text in a given Div with a span.
$(document).ready(function(){
$('.format').click(function(){
var highlight = window.getSelection();
var spn = '<span class="highlight">' + highlight + '</span>';
$('.conttext').content().replace(highlight, spn);
});
});
A function of this nature could be used to provide formating options to an HTML contenteditable DIV.
Something is clearly wrong though as it does not currently work.