yes, it indeed is selection = getSelectedText(); if(selection.length >= 3) { $(this).html($(this).html().addClass("selected"); }
to selection = getSelectedText(); if(selection.length >= 3) { var $spn = $("<span></span>").html(selection).addClass ("selected"); // append/set this '$spn' inside another DOM object } to note, your original/non-working code seems to be trying to set the ".html" of an <input> or <textarea>, that's not a valid method to do on such items On Jan 18, 11:46 am, Mircea <i...@amsterdamsat.com> wrote: > Yes, I want to be able to select a part of the text and add a span to > it. Can this be done? > Thank you.