jquery - Update element within a cloned div -
i have div
<div id="mydiv"><h3 id="myheader"></h3 ></div>
and have created few clones of div
var $divclone1 = $('#mydiv').clone(); var $divclone2 = $('#mydiv').clone(); var $divclone3 = $('#mydiv').clone();
i want able set value of myheader different in each of 3 clones - idea list individual clones screen different myheader values.
how can achieved jquery?
ids should unique on page. i'd suggest using class names instead of ids. if need unique ids each element, apply them after cloning.
i use jquery once reference original div, make clones of that.
<div class="mydiv"><h3 class="myheader"></h3 ></div> var $mydiv = $('.mydiv'), $divclone1 = $mydiv.clone(), $divclone2 = $mydiv.clone(), $divclone3 = $mydiv.clone(); $divclone1.find('.myheader').attr('id', 'clone1').text('clone1'); // attach dom $divclone2.find('.myheader').attr('id', 'clone2').text('clone2'); // attach dom $divclone3.find('.myheader').attr('id', 'clone3').text('clone3'); // attach dom
good luck!
Comments
Post a Comment