Consider following HTML markup:
<form action="">
<div class="row subtitle">
<span>Some stuff.</span>
</div>
<div class="more_subtitles"></div>
<a href="#" class="white add_more"><span>Add more</span></a>
</form>
And jQuery:
$('.add_more').live('click', function() {
var el_of_form, subtitle, more_subtitles;
el_of_form = $(this).closest('form');
subtitle = $(el_of_form).find('.subtitle');
more_subtitles = $(el_of_form).find('.more_subtitles');
console.log(subtitle);
console.log(more_subtitles);
$(more_subtitles).add(subtitle);
return false;
});
Why isn’t it working? console.log() finds those elements…
What I want to accomplish is that when button is presses, it clones subtitle element and add it in more_subtitles element. And user can repeat it again and again.
1 Answer