Dave's Brain

Browse - 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:

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, }); }

Add a comment

Sign in to add a comment
Copyright © 2008-2018, dave - Code samples on Dave's Brain is licensed under the Creative Commons Attribution 2.5 License. However other material, including English text has all rights reserved.