2012-05-03 43 views
0

我试图使用下面的代码更改jQuery对话框标题栏图像,但它不起作用。需要更改jquery对话框标题栏图像

我的对话框&标题栏图像看起来就像这样:

enter image description here

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

如何去改变它任何建议?由于

+0

它不应该,那你试试?这个图像是否存在? –

回答

2

你必须添加一个CSS规则:

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

看到demo

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 dialog image for the title :))

工作演示:

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

点击上面演示的click me,你会看到里面的小图像的对话窗口。

良好读取链接:

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

+0

我想使用其他图像,而不是灰色的标题栏图像...如何做到这一点。 – Thomas

+0

Saweet @Thomas http://jsfiddle.net/V5NkV/10/或http://jsfiddle.net/V5NkV/5/ AHHHAAA!得到你,看下面只需改变'..ui-dialog-titlebar',你可以改变标题为图像,有一个不错的小卡! –