开发者

how to set background images when jquery dialog ui is open()

how to set background images开发者_高级运维 when jquery dialog ui is open()

how can i set background images of html page in jquery


The jQuery UI Dialog won't prevent you from altering the page behind it with javascript, even if the dialog is modal.

The following will work:

$('body').css('background','url(path/to/your/image.jpg)')

If you want to set that background image when your UI Dialog opens, then you would bind to the dialog's "open" event, like so:

$( ".selector" ).dialog({
   open: function(event, ui) { ... }
});

or...

$( ".selector" ).bind( "dialogopen", function(event, ui) {
  ...
});

If you're experiencing trouble setting a new background image on the page, it may be that there's an element being styled on your page with a more specific CSS selector than you're providing. For instance, you may have a wrapper div nested just inside the body that has a background image, which would knock out the body tag's.


Your question is not entirely clear, however:

You can use .addClass to add a css class to an element. The css class can have a background image defined.

.sky
{
   background-image:url('sky.png');
}

$('#someElement').addClass('sky');


In jQuery UI, when the dialog box is open, the page background changed by setting the appropriate values of the ui-widget-overlay class. You can check the background by changing the background property or use other CSS properties..

You can use the css method which jQuery provides to modify the values

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜