Javascript: How stop function wich is started on $(function(){})
<p>Problem is: i create function then call this function when page load, also i need call same function, but not double existing. Just stop from $(function(){}) and call again when click on element. </p>

<p>I have something like this: </p>

<pre><code>function myfunction(){
    console.log('message');
}

$(function(){
    myFunction();

    $('#id').click(function(){

     ...some code here ...
     myFunction();

});
})
</code></pre>

<p>when page load console give me: "message" - it's ok, but when click on #id then give this message twice, if again then 3 times;</p>

<hr>

<p>Here my code</p>

<pre><code>function select_cta(){
    $('.cta-id').click(function(){
        console.log('-');
        $('.cta-id').removeClass('active');
        $(this).addClass('active');

        var cta_arr = parseInt($(this).attr('id').replace('cta-button-', ''))-1;

        $('.cta-image').fadeOut(300).removeClass('active');
        $('#'+$(this).attr('id').replace('cta-button', 'cta-image')).fadeIn(300).addClass('active');
        if(cta_data[cta_arr]){
            $('.cta-actions #cta_id').val(cta_data[cta_arr].id);    
        }
        else{
            $('.cta-actions #cta_id').val('');
        };

        if(cta_data[cta_arr]){          
            $('.cta-actions #cta_link').val(cta_data[cta_arr].link);
        }
        else{
            $('.cta-actions #cta_link').val('');
        };

    });

}

$(function(){

    select_cta();

    $('.add-new-cta').click(function(){
        var new_tab = parseInt($(this).prev().attr('id').replace('cta-button-',''))+1;
        $(this).before('&lt;div id="cta-button-'+new_tab+'" class="cta-btn cta-id empty" style="display:none;"&gt;&lt;span&gt;'+new_tab+'&lt;/span&gt;&lt;span class="onair"&gt;ON&lt;/span&gt;&lt;/div&gt;');
        $('#cta-button-'+new_tab).fadeIn(300);
        $('.cta-images').append('&lt;div id="cta-image-'+new_tab+'" class="cta-image " style="display:none"&gt;&lt;img src="/assets/images/page/placeholder_cta.gif"&gt;&lt;/div&gt;');

        select_cta();   

    })
});
</code></pre>
