0

我尝试使用以下代码更改 jQuery 对话框标题栏图像,但它不起作用。

我的对话框和标题栏图像如下所示:

在此处输入图像描述

$("#dialog").dialog({
    title: '<img src="myImage.jpg" />'
});​​​​​​​​​​​

有关如何更改它的任何建议?谢谢

4

2 回答 2

2

你必须添加一个 CSS 规则:

.ui-dialog-titlebar{
    background:url(http://www.elementalsurface.com/beech-wood.jpg);
}​

演示

于 2012-05-03T12:44:29.517 回答
1

此代码将很好地了解如何执行此操作:

jQuery:

var $Dialog_div;

function fnOpenDialog() {
    $Dialog_div = $('<div id=\'ThisDialog\'>Hello</div>').prependTo('body');

    $Dialog_div = $('#ThisDialog').dialog({
        autoOpen: true,
        draggable: true,
        resizable: true,
        title: 'Dialogimage<img src="http://dummyimage.com/100x30/000/fff&text=I\'m+an+image,+hi!" />',
        modal: true,
        stack: true,
        height: ($(window).height() * 0.95),
        width: ($(window).width() * 0.9),  
        buttons: {
            'OK': function() {
                $Dialog_div.dialog('close');
            }
        }
    });  
}

$('#ClickMe').click(fnOpenDialog);​

HTML:

<!-- This is more than likely an Adobe issue where it thinks it should be in the front
     all the time no matter what however it is very annoying that you can't open
     a dialog over a PDF-->

<body>
    <div id='ClickMe'>Click here!</div>
    <br/>
    <div></div>
    <br/>      
</body>

(可能是巧合,您的对话框图像与此处的示例非常相似:标题的 jQuery ui 对话框图像:))

工作演示:

http://jsfiddle.net/V5NkV/http://jsfiddle.net/V5NkV/10/

单击click me上面演示中的 ,您将看到带有小图像的对话窗口。

不错的阅读链接:

http://jqueryui.com/demos/dialog/

于 2012-05-03T12:29:02.187 回答