$("button").click(function(){ $("div").empty(); });
function isEmpty( el ){ return !$.trim(el.html()) } if (isEmpty($('#element'))) { // do something }
// removes only text, no changes to children $('#YourDivId').contents().filter((_, el) => el.nodeType === 3).remove();