This code working fine, Here I have remove extra white spaces in TextEditor.
var htmlstring = $("#textareaCode").html().replace(/( )*/g, "");
for more Deatils refer: http://www.infinetsoft.com/Post/How-to-remove-nbsp-from-texteditor-in-jQuery/1226#.V0J-2fl97IU