jQuery 对话框 - 如何为每个对话框使用不同的样式?

标签 jquery css jquery-ui jquery-ui-dialog jquery-dialog

我使用 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/

相关文章:

html - Flexbox 垂直和水平居中

html - css3 webkit transition transform 翻译 : invalid property value?

jquery - 使用 bootstrap-datepicker 显示日期之后的星期几

ios - 如何使用 Ionic 更改 iOS 上进度条的样式?

javascript - 切换所选日期 jQuery Datepicker

javascript - HTML、JQuery分离加载div

javascript - iOS Safari 过度滚动 : Pulling down vs. 弹跳

Jquery 将父级替换为第一个子级

javascript - jQuery AJAX 多个函数获取结果?

jquery - 这段特定代码片段中的 jQuery $(this) 指的是什么?