function prepDialogDiv(id) { if ($('#'+id).size() == 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, }); }
Programming Tips - I don't like manually creating div's for my jQuery dialogs.
Date: 2011aug8
Language: javaScript
Library: jQuery
Platform: web
Q. I don't like manually creating <div>'s for my jQuery dialogs.
Can I do it programatically?
A. Yes, here's a function to do that: