How to apply jquery code to different targets without rewriting existing code?
<p>Is it possible to execute existing jquery code but apply it to alternate targets?</p>

<p><strong>EXAMPLE</strong></p>

<pre><code>$('#btn1').click(function() {
    $('#div1').fadeOut()
});
</code></pre>

<p>Can this code be reused to execute from #btn2 and target #div2 without rewriting the code.</p>

<p><strong>SOLUTION</strong></p>

<pre><code>&lt;a href="#"class="btn" data-id="35"&gt;Click&lt;/a&gt;

$('.btn').click(function() {
    $('#div'+$(this).data('id')).fadeOut()
});
</code></pre>
