How to remove text inside an element with jQuery?
$('li').not('div,a').text('')
Try this, untested
Edit
$('li').contents().filter(function(){ return !(this.tagName == 'DIV' || this.tagName == 'A');}).remove();
$('li').html($(this).children())
You can try this, it should work. Clean and easy.