What is the best way to remove all children from a div, but leave the text that is directly inside the div in jquery.
I tried .childre (). remove (), but this adds a lot of spaces in firefox and opera. However, it works fine.
Try:
$('#element_id').children().remove().end().text($.trim($('#element_id').text()));
$.trim remove surrounding spaces from text.
$.trim