Programming Tips - Old - How do you ensure the div required by jQuery dialog is here?

Date: 2011jul8 Language: javaScript Library: jQuery Platform: web Q. How do you ensure the <div> required by jQuery dialog is here? A. I use this function:
function prepDialogDiv(id) { if ($('#' + id).length == 0) { $('body').append('<div id=' + id + '></div>'); } }
Besides ensuring that the <div> is there this also means I don't have to put the <div> into the html page which seems clean to me.