This is my code :
HTML
<div style="display:none;">
<div id="example">
<div class="child">Hello</div>
</div>
</div>
<div id="result"></div>
jQuery
htmlSedi="";
sedi(1);
sedi(2)
$("#result").append(htmlSedi);
function sedi(param) {
var htmlSede = $('#example');
if(param==1)
htmlSede.find('.child').hide();
htmlSedi=htmlSedi+htmlSede.html();
}
the result I aspect is to get at least one "Hello" printed into the div result, but in fact it doesnt; I think the problem is on :
var htmlSede = $('#example');
which point to the same object. So, how can I create a new "instance" of #example?
You can use
.clone()for this.jQuery Docs