有没有可能打开一个jQuery UI对话框没有标题栏?
当前回答
这对我很有效
open: function(event, ui) {
$(".ui-dialog-titlebar", $(this).parent())
.hide();
Full
$speedbump.dialog({
dialogClass: 'speedbump-container',
autoOpen: false,
closeOnEscape: false,
modal: true,
resizable: false,
draggable: false,
create: function () {
$speedbump
.closest('.ui-dialog')
.attr('id', 'speedbump-container');
},
open: function(event, ui) {
$(".ui-dialog-titlebar", $(this).parent())
.hide();
}
其他回答
试试这个
$("#ui-dialog-title-divid").parent().hide();
将divid替换为相应的id
实际上还有另一种方法,直接使用对话框小部件:
您可以这样获得对话框小部件
$("#example").dialog(dialogOpts);
$dlgWidget = $('#example').dialog('widget');
然后做
$dlgWidget.find(".ui-dialog-titlebar").hide();
仅在该对话框中隐藏标题栏
并且在一行代码中(我喜欢链接):
$('#example').dialog('widget').find(".ui-dialog-titlebar").hide();
不需要在对话框中添加一个额外的类,直接就可以了。对我来说没问题。
你尝试过jQuery UI文档的解决方案吗? https://api.jqueryui.com/dialog/#method-open
正如它所说,你可以这样做……
在CSS中:
.no-titlebar .ui-dialog-titlebar {
display: none;
}
在JS:
$( "#dialog" ).dialog({
dialogClass: "no-titlebar"
});
下一种形式解决了我的问题。
$('#btnShow').click(function() { $("#basicModal").dialog({ modal: true, height: 300, width: 400, create: function() { $(".ui-dialog").find(".ui-dialog-titlebar").css({ 'background-image': 'none', 'background-color': 'white', 'border': 'none' }); } }); }); #basicModal { display: none; } <script src="http://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.3/jquery-ui.min.js"></script> <link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.3/themes/smoothness/jquery-ui.css" /> <div id="basicModal"> Here your HTML content </div> <button id="btnShow">Show me!</button>
当隐藏Dialog标题栏时,我发现,即使display为none,屏幕阅读器仍然会读取它。如果您已经添加了自己的标题栏,它将同时显示这两种内容,从而造成混淆。
我所做的是使用$(selector).remove()从DOM中删除它。现在屏幕阅读器(和其他人)将看不到它,因为它已经不存在了。
推荐文章
- 停止jQuery中的所有活动ajax请求
- 在$.ajax()中将数组传递给ajax请求
- JavaScript数据网格数百万行
- 我可以在JavaScript中获得当前运行函数的名称吗?
- 使用jQuery选择多个类
- 如何创建一个jQuery函数(一个新的jQuery方法或插件)?
- jQuery -添加额外的参数提交(不是ajax)
- 如何清除所有<div>的内容在一个父<div>?
- 如何在svg元素中使用z索引?
- 如何求一个数的长度?
- 使用jQuery获取第二个孩子
- .append(), prepend(), .after()和.before()
- 如何将JavaScript文件链接到HTML文件?
- jQuery的窗口大小调整
- 找到jQuery中所有未选中的复选框