3
I am using the "cloning" of Divs in jquery, and within them I have other Ivs that when clicking on a button ex.: DIV 1, DIV 2, DIV 3 with javascript shows the content of each div. Only when adding the new div(cloned) when clicking on the button to show the hidden div inside the cloned one appears the change only in the original div, and in the cloned one it is the same..
Using the Jquery "CLONE" command in div "encompasses" only shows/hides in the original and not in the cloned.
GOES 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>
You can show your code?
html
andjs
– Giovane
Put your code (html, css and javascript) here, or better yet, in jsfiddle that will be easier to help you.
– Almeida
I changed and added the code to get better...
– Alh
Surely the problem is that you do everything for the Divs ID, and when you clone, you end up cloning it too, ideally you change that information when you clone
– Sorack