我使用 jQuery UI 对话框来显示网站上的不同对话框。现在我想知道是否有一种简单的方法可以为不同的对话框使用不同的样式?
例如像“确实删除...”这样的警报应该与其他消息有不同的风格...
现在,对话框中使用了一些类:
<div id="dialog-confirm" title="Title of dialog">Text of dialog</div>
然而,实际的样式应用于.ui-widget-header
,,我在源文本中找不到任何地方,所以我猜jQuery在某个时候替换了它,是这样的真的吗?
编辑:来自 docs.jquery.com:
Sample markup with jQuery UI CSS Framework classes
<div class="ui-dialog ui-widget ui-widget-content ui-corner-all ui-draggable ui-resizable">
<div class="ui-dialog-titlebar ui-widget-header ui-corner-all ui-helper-clearfix">
<span id="ui-dialog-title-dialog" class="ui-dialog-title">Dialog title</span>
<a class="ui-dialog-titlebar-close ui-corner-all" href="#"><span class="ui-icon ui-icon-closethick">close</span></a>
</div>
<div style="height: 200px; min-height: 109px; width: auto;" class="ui-dialog-content ui-widget-content" id="dialog">
<p>Dialog content goes here.</p>
</div>
</div>
Note: This is a sample of markup generated by the dialog plugin, not markup you should use to create a dialog. The only markup needed for that is <div></div>.
为不同的对话框提供不同样式的最佳方式是什么?
最佳答案
也可以直接从 jQuery 站点:
$( ".selector" ).dialog({ dialogClass: "alert" });
它说
The specified class name(s) will be added to the dialog, for additional theming.
关于jQuery 对话框 - 如何为每个对话框使用不同的样式?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11620067/