Clone div into DOM once per click
I have the following code;
$('[class*="time-span"]').on('click', function () {
var
modelPanel
=
$
(
'.model-detail-panel'
);
modelPanel
.
clone
().
insertAfter
(
'.timeline'
).
slideToggle
(
'fast'
,
function
()
{
$
(
'html,body'
).
animate
({
scrollTop
:
$
(
this
).
offset
().
top
},
500
);
});
});
This inserts the 'model-detail-panel' div into the DOM after the 'timeline' class. The problem I have is that the DOM has quite a few timeline classes and this code is inserting the div after each one but I only want it added after I click one (any one, not all together).
How can I do this?