I'm using the "cloning" of divs in jquery, and inside of them I have other divs that when clicking on a button eg: DIV 1, DIV 2, DIV 3 with javascript shows the contents of each div. But when I add the new div (cloned) when I click the button to show the hidden div inside the cloned the change appears in the original div only, and the cloned one stays the same ..
When using the "CLONAR" command of Jquery in the div "engloba" only the show / hide works in the original, not the cloned.
FOLLOW BELOW:
<script>
function Listagem(tr) {
if (tr == 1) {
document.getElementById('div1').style.display="block";
document.getElementById('div2').style.display="none";
document.getElementById('div3').style.display="none";
}else if (tr == 2) {
document.getElementById('div1').style.display="none";
document.getElementById('div2').style.display="block";
document.getElementById('div3').style.display="none";
}
else if (tr == 3) {
document.getElementById('div1').style.display="none";
document.getElementById('div2').style.display="none";
document.getElementById('div3').style.display="block";
}
</script>
<!-- Clona DIVS em jquery-->
<script type="text/javascript" src="http://code.jquery.com/jquery-1.11.2.min.js"></script><script>$(document).ready(function(){$("#mais").click(function() {
linha = $("#engloba").html();
$("#conteudo_engloba").append("<br />"+linha+"<br />");
});
});
</script>
<!-- botao que "clona" a div (engloba) -->
<form>
<input type="button" name="" value="+" id="mais">
</form>
<div id="conteudo_engloba">
<div id="engloba">
<a onClick="Listagem(1);" id="btDetalhes" >DIV1</a>
<a onClick="Listagem(2);" id="btDetalhes" >DIV2</a>
<a onClick="Listagem(3);" id="btDetalhes" >DIV3</a>
<div id="div1">DIV 1</div>
<div id="div2">DIV 2</div>
<div id="div3">DIV 3</div>
</div>
</div>