tags:

views:

18

answers:

1

I am using jQuery with TinySort and I like to sort by prices and show only certain elements based on their classes.

I am able to get the sorting down easily just not the hiding and showing of elements. Can you take this that one step further?

<div id="properties">
    <div id="389900" class="commerical">389900</div>
    <div id="835000" class="residential">835000</div>
    <div id="549000" class="commercial">549000</div>
    <div id="650000" class="residential">650000</div>
    <div id="439000" class="commercial">439000</div>
</div>

I am sorting them correctly by using.

$('#properties > div').hide();
$('#properties > div').tsort({order:'desc', attr:'id'}, 'div[class=commercial]' ).show();

I just hoping that I could get the div elements by the class commercial to show why others are hidden. This just gives me all of the above elements. Any suggestions on where I am going wrong?

A: 

I'm not that familiar with tinysort but I think? that's not a correct way to use the API.

Rather try this instead:

$('#properties > div').tsort({order:'desc', attr:'id'});
$('#properties > div.residential').hide();

Later on if you want to show commercial you can do this:

$('#properties > div.commercial').hide();
$('#properties > div.residential').show();
Mark