Programming Tips - jQuery: programmatically make div's for my dialogs

Date: 2011aug8 Language: javaScript Library: jQuery Platform: web Q. jQuery: programmatically make <div>'s for my dialogs A. Here's a function to do that:
function prepDialogDiv(id) { if ($('#' + id).length == 0) { $(document.body).append('<div id=' + id +'></div>'); } else { $('#' + id).html(''); } } function exampleUse() { prepDialogDiv('hello'); $('#hello').html('Hello!'); $('#hello').dialog({ width: '60%', height: 650, title: 'Hello', modal: true, }); }