You are removing elements and then targeting them using prepend. You can’t prepend content to no more existing element. Target again the content of the DIV, using end()
:
var ur_text = "your text";
$('.booktext').contents().filter(function(){
return this.nodeType !== 1;
}).remove().end().prepend('your text');
1
solved Why can’t I simply prepend text? [closed]