how to force one dialog box to be above the other?

Asked

Viewed 52 times

1

I have a dialog box that calls a 2, only this 2 needs to stay above the 1 how do I force this via javascript? or any other way, except z-index that I tried and is not going.

  • z-ndex style only works on the object that already exists a previously defined position. Try setting position for your dialog boxes and apply the z-index.

  • @I already did that. I have already used exactly this code in another part and it works perfectly, but when I repeat this same part elsewhere it does not work. Got some js I can force?

  • So please edit your question and add the code you tried to do. Also beware of generating a [mcve].

  • Put more things on so we can help you.

1 answer

0


As you have not posted any code or something like I made an example with Divs , if my example did not serve edit the question, and comment below so I can modify and thus help you better.

$(function(){
  $('#mostrarDiv').click(function(){
    $('.div2').show(250);
  });
  $('#ocultarDiv').click(function(){
    $('.div2').hide(250);
  });
});
.div1{
  position: absolute;
  top: 0;
  left: 0;
  width: 200px;
  height: 200px;
  background: green;
}

.div2{
  display:none;
  position: absolute;
  top: 30;
  left: 30;
  z-index: 5;
  width: 200px;
  height: 200px;
  background: red;
}

#mostrarDiv{
  position: absolute;
  top: 300px;
}

#ocultarDiv{
  position: absolute;
  top: 300px;
  left: 130px;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="div1"></div>
<div class="div2"></div>
<br>
<input type="button" id="mostrarDiv" value="Chamar div 2">
<input type="button" id="ocultarDiv" value="Ocultar div 2">

Browser other questions tagged

You are not signed in. Login or sign up in order to post.