简体   繁体   中英

Why won't my jQuery UI dialog work?

Why won't my jQuery UI dialog work?

It works if I put the div on the page in the html but I want to rather dynamically insert it as below then remove it with a click event.

var d = $("<div id='my' >any text</div>");

d.dialog({

     modal: true

});

Later I want to close it in another event with

$('td').click(function(){

   $("#my").dialog("close");

)};

You create the element, but don't seem to add it to the DOM? If you use the .appendTo() method, you can add it to the DOM, prior to calling the .dialog() method.

Try something like this instead

$("<div id='my'>any text</div>").appendTo("body"); 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM