Convert code to reusable object
<p>I have some code, part of it shown below, that I call multiple times to modify an element on the page:</p>

<pre><code>if ($('.el').length == 0)
{
    $('&lt;div class="el active"&gt;Good job!&lt;/div&gt;').hide().appendTo('body').fadeIn();
}
else
{
    $('.el').fadeOut(function()
    {
        $('.el').html('Good job!').addClass('active').fadeIn();
    });
}
</code></pre>

<p>Since I call this same piece of code multiple times (with varying messages and different classes at times), I want to make it so that I can simply do something like:</p>

<pre><code>$('.el').messager({
    message: 'Good job!',
    class: 'active'
});
</code></pre>

<p>How can I convert what I have into what I need?</p>