Alex Rivera | Logout

Jquery - Remove only text content from a div

Asked 2010-08-06T08:11:46.840
45

is possible to remove only text content from a div, i.e. leave all other elements intact and only remove text that is directly inside a div?

Edit
Report

1 Answer

2

The simplest way would be something like this:

$('#div').html($('<div>').append($('*', '#div')).html());
answered 2010-08-06T08:21:51.787

Your Answer