Need Javascript help

Seems like you want to do something like this Isotope · Filtering

There are isotope tutorials on this forum which you can search for.