23rd of June 2010 1
There are a lot jQuery scripts to do most about anything. However it's always better to create small custom scripts for whatever you might need it for since you that way will in the future be able to do whatever you'd like. So i present to you a simple jQuery script to allow you to show and hide anything with multiple instances.

jQuery code
This is quite simple. "var hiddendivs" is where you define which selectors should be the hidden ones. Then you can just mark your div's (or whatever you'd like) with the CSS class hidden.
Next is "var showmore" where we define which selector and class should activate a hidden div, in this case it's "a.showhidden".
After that we go into the funtion itself where we choose to toggle a class when one click the a-tag in this case (a.showhidden) and now to the more important part:
"$(this).parent().nextAll('div.hidden:first').slideToggle(300)" is where we actually say that we should go one step back in the code (parent) and then look for the first div.hidden within it and slideToggle it with a duration of 300.
CSS code
XHTML
Be sure to check the xhtml source (wordpress stripts my p-tags!) and jquery source code in the example to get a better grasp on just how this works. Note that the parent is very important for this to work but if you like another setup or flow you will have to script this a bit different.
If you still have no idea on how to get this to work feel free to comment and ask.
Web design portfolio 3:37 pm 18/08 of 2010
great, thanks for the code!
ReplyCopyright Tommie Hansen since 2010. All rights reserved. Design and the Absolute Theme by Tommie Hansen.