简体   繁体   中英

jQuery dialog not working Chrome Extension

I'm working on chrome extension. I have problem with opening jQuery dialog box.

I have this code

if (window.jQuery) {
    alert("YES");
    $("<div>My div content</div>").dialog();
    alert("YES2");
}
else {
    alert("NO");
}

first alert works but second one fails to open, so there some problem with

$("<div>My div content</div>").dialog();

any ideas what's wrong with it or how to fix

You need to append your <div> to DOM before make dialog from it:

$("<div>My div content</div>").appendTo( 'body' ).dialog();

Probably there something wrong w/ scripts connections. jquery should be included before jquery-ui

Demo

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