How to overwrite a div from another using jquery

Asked

Viewed 680 times

0

When I click on the + in my select, my system shows and adds an item in the div with "tabs". inserir a descrição da imagem aqui

only when it shows the div that was hidden, it was on top of my select (as shown in the image).

function:

 function add(id_sistema){

    $('#tabs').append("<div id='tabs-2'></div>");

    $("#tabs").tabs("refresh");
    $("#tabs").show();
    $("#divDataJson").show();

}

Briefly it’s this function when I click on +.

  • 3

    if you take this div from id and add a z-index to it not right? example $('#tabs-2'). css("z-index","1");

  • worked, that I did not know thank you. want to create a response?

  • will create thanks @Juliohenrique97

  • it would not be easier to put the z-index in her style at the time of append ali in the string instead of using jQuery for that? <div id='tabs-2' style='z-index: 1;'></div>

1 answer

1


Take the id of this div and add a z-index to it with the "css" function of jquery follows below an example

$(document).ready(function(){
  $('#addZindex').on('click',function(){
    $('#exemplo').css("z-index","1");
  });

});
#exemplo{
  height: 200px;
  width: 200px;
  background-color: red;
  position:absolute;
}

#exemplo2{
  height: 200px;
  width: 200px;
  background-color:blue;
  position:absolute;
  left: 30px;
}

#addZindex{
  height: 50px;
  width: 100px;
  z-index: 1;
  float: right;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div id="exemplo"></div>
<div id="exemplo2"></div>
<button id="addZindex">Mudar Z-index</button>

Browser other questions tagged

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