I have a div and there is a text in it.I want a part of that text to be selected programmatically according position value of characters.
Try using .html() , String.prototype.slice(). To select "llo world" call .slice() with parameters 3, 12
.html()
String.prototype.slice()
.slice()
3, 12
$("#textdiv").html(function(i, html) { var selected = html.slice(3, 12); return html.replace(new RegExp("("+selected+")"), "$1") })
Hello world. I am a friend.