Given this string:
var str = 'One two three four five';
and this parameters:
position: 8
length: 5
I would like to wrap the part of the string that starts at the given position and has the given length inside SPAN tags. In this case, I want this result:
'One two <span>three</span> four five'
How can this be done most elegantly?
Update: My own solution is here: http://jsfiddle.net/simevidas/XjbvN/
1 Answer