animate show/hide from css class

Upalnite

New Member
I'm new to JavaScript and jQuery so please be gentle with me. I'm trying to animate a show/hide of several divs based on if it has a certain class or not.Basically, I'm creating a site for a photographer and have a portfolio section with a list of filters along the top, each div has a class of "portfolio-items" as well as additional classes for all the categories it's in, so family / wedding / kids / couples. any image can have multiple classes on it.What I want to do is click on the family link and it hides anything that doesn't have the family class on it. If I then click on wedding it closes anything that's currently open that doesn't have the wedding class on it and opens anything thats currently closed that does have the wedding class on it.I currently have it working with the code below but this simply closes everything and then opens the ones that have the class required. Plus I don't know how to add an animate to it.\[code\]function portfolioItems(filter) { $(".portfolio-items").hide(); $("."+filter).show(); }function initEventHandlers () { $(".port-all").click(function () { $(".portfolio-items").show(); return false; }) $(".port-wedding").click(function () {portfolioItems("wedding");return false; }) $(".port-family").click(function () {portfolioItems("family");return false; }) $(".port-kids").click(function () {portfolioItems("kids");return false; }) $(".port-couples").click(function () {portfolioItems("couples");return false; }) }\[/code\]The HTML is...\[code\] <div class="portfolio-container"> <div class="portfolio-links"> <a href="http://stackoverflow.com/questions/14387477/#"><img alt="All" class="port-all" src="http://stackoverflow.com/questions/14387477/images/port-all.png" /></a> <a href="http://stackoverflow.com/questions/14387477/#"><img alt="family" class="port-family" src="http://stackoverflow.com/questions/14387477/images/port-family.png" /></a> <a href="http://stackoverflow.com/questions/14387477/#"><img alt="wedding" class="port-wedding" src="http://stackoverflow.com/questions/14387477/images/port-wedding.png" /></a> <a href="http://stackoverflow.com/questions/14387477/#"><img alt="couples" class="port-couples" src="http://stackoverflow.com/questions/14387477/images/port-couples.png" /></a> <a href="http://stackoverflow.com/questions/14387477/#"><img alt="kids" class="port-kids" src="http://stackoverflow.com/questions/14387477/images/port-kids.png" /></a> </div> <div class="portfolio"> <div class="portfolio-items wedding couples family"></div> <div class="portfolio-items kids"></div> <div class="portfolio-items wedding kids family"></div> <div class="portfolio-items couples"></div> <div class="portfolio-items couples kids family"></div> <div class="portfolio-items wedding"></div> </div> </div>\[/code\]
 
Back
Top