I need to add html unit by onclick a button,
<div class="unit">
....
<a class="add">Add</a>
</div>
in jquery,
// add function
$('.add').on('click', function (e) {
.....
});
This is working without any issues. My problem is, I'm adding the same html unit and I need to add more units. I know I need to initialize the add function
again inside the add function
. Then it is working.
// add function
$('.add').on('click', function (e) {
.....
$('.add').on('click', function (e) {
.....
});
});
But I have more codes inside the add function
, So how can optimize it without adding twice ?