jQuery, filtered list using links and a data selector
<p>I have a list that when a link is selected, the div's associated will hide.</p>

<p>First of all, is there an easier way to write the code to make the selector find the data associated to the button pressed?  </p>

<p>Secondly, when multiple links are selected and one is clicked again, the list goes back to default.  Is there a fix for this?</p>

<pre><code>    $(document).ready(function() {

        $('#show-free').click(function() {

            if ($('#show-free').hasClass('active')) {
                $('.book[data-price!="0"]').trigger('show')
                $(this).removeClass('active');

            } else {
                $('.book[data-price!="0"]').trigger('hide');
                $(this).addClass('active');
            }
        });

        $('#show-paid').click(function() {

            if ($('#show-paid').hasClass('active')) {
                $('.book[data-price="0"]').trigger('show')
                $(this).removeClass('active');
            } else {
                $('.book[data-price="0"]').trigger('hide');
                $(this).addClass('active');
            }
        });

        $('#show-new').click(function() {

            if ($('#show-new').hasClass('active')) {
                $('.book[data-weeks-on-list="0"]').trigger('show')
                $(this).removeClass('active');
            } else {
                $('.book[data-weeks-on-list="0"]').trigger('hide')
                $(this).addClass('active');
            }
        });


        $('#show-old').click(function() {

            if ($('#show-old').hasClass('active')) {
                $('.book[data-weeks-on-list!="0"]').trigger('show')
                $(this).removeClass('active');
            } else {
                $('.book[data-weeks-on-list!="0"]').trigger('hide')
                $(this).addClass('active');
            }
        });


        $('.book').on('show', function() {
            $(this).show('slow');
        }).on('hide', function() {
            $(this).hide('slow');
        })


    });
</code></pre>
