How to define a jQuery function properly
<p>I want to write an jquery function because otherwise I have to write some code over and over.</p>

<p>Here is wat the function was first: </p>

<pre><code> $(".checkbox-car").click(function(){
            $(this).toggleClass('checked-car')
        });

         $(".checkbox-bus").click(function(){
            $(this).toggleClass('checked-bus')
        });
</code></pre>

<p>And this is what I tried to do with my own function:</p>

<pre><code>    $.fn.checkedFunction = function(Clicked, Checked){
        $(this).click(function(){
            console.log('check');
            $(Clicked).toggleClass(Checked);
        });
    }

    $('.checkbox-car').checkedFunction('.checkbox-car','.checked-car');
</code></pre>

<p>But I get the error that the checkedFunction is not defined.</p>

<p>What am I doing wrong here can someone help me out?</p>