在指定jQuery UI对话框时,是否可以为我的标题而不是纯文本放置图像?
由于
答案 0 :(得分:9)
您可以提供任何HTML作为title
选项,如下所示:
$("#dialog").dialog({
title: '<img src="myImage.jpg" />'
});
You can see an example in action here
或者,作为另一个惹恼用户地狱的演示,you could do this:
$("<div />").dialog({
title: '<marquee>Hello</marquee>'
});
答案 1 :(得分:0)
您也可以使用HTML进行设置,尽管对话框以文本作为标题,但是您可以通过扩展对话框属性(例如
)来进行更改 $(document).ready(function() {
$.widget("ui.dialog", $.extend({}, $.ui.dialog.prototype, {
_title: function(title) {
var $title = this.options.title || ' '
if( ("titleIsHtml" in this.options) && this.options.titleIsHtml == true )
title.html($title);
else title.text($title);
}
}));
$('div#thedialogg').dialog({
title:"<img src='images/logo-new.png' class='logo_size'>",
titleIsHtml:true,
autoOpen: false,
height: 581,
width: 1000,
modal: false,
draggable: false,
resizable: false,
position: 'center'
})
})