简体   繁体   English

如何将关闭按钮放在jQuery的标题栏中弹出

[英]how to put the close button in the title bar of jquery pop up

Here is the fiddle https://jsfiddle.net/evbvrkan/ 这是小提琴https://jsfiddle.net/evbvrkan/

This is a very big project so can't change many things, now the requirement is to put the x button of the second pop up(which comes from clicking the 'Click me 2 ' button ) in the title bar or any other way of making the appear on the 2nd dialog to close that. 这是一个非常大的项目,因此不能更改很多内容,现在的要求是将第二个弹出窗口的x按钮(来自单击“ Click me 2”按钮)来自标题栏或其他任何方式使其出现在第二个对话框中以将其关闭。

As you can see in the CSS that every pop-ups title close icon is disabled, I cant change that. 如您在CSS中所看到的,每个弹出窗口标题关闭图标都被禁用,我无法更改它。

I tried many of the solution from stackoverflow and nothing worked , to put a button in title bar of a dialog or X sign 我尝试了来自stackoverflow的许多解决方案,但没有任何效果,将按钮放在对话框或X符号的标题栏中

HTML 的HTML

<div id="myFirstDialog">
    This is the content of my modal dialog box

</div>

<button id="clickMe">Click Me</button>

<div id="my2ndDialog" >
    This is the content of my 2nd modal dialog box

</div>

<button id="clickMe2">Click Me 2</button>

JS JS

$("#myFirstDialog").dialog({
    autoOpen  : false,
    modal     : true,
    title     : "A Dialog Box"
   });

$('#clickMe').click(function() {
    $("#myFirstDialog").dialog("open");
});

$("#my2ndDialog").dialog({
    autoOpen  : false,
    modal     : true,
    title     : "A Dialog Box",
    buttons   : {
              'X' : function() {
                  $(this).dialog('close');
              }  
              }
   });

   $('#clickMe2').click(function() {
    $("#my2ndDialog").dialog("open");
});

CSS 的CSS

.ui-dialog-titlebar-close {
    visibility:hidden;
}

Add a class using dialogClass to the ui dialog you want to show the close button and then add css to show based on that class: 使用dialogClass将一个类添加到要显示关闭按钮的ui对话框中,然后添加css以基于该类显示:

https://jsfiddle.net/jmcjzkyv/ https://jsfiddle.net/jmcjzkyv/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM