i used this script to animate some divs with jquery and css. now i would like to use more than these two buttons. instead there should be several lists underneath. but i cannot just copy each jquery script and change the name of the vars.
here is the example: http://jonathanstark.com/labs/simple-sliding-example-using-css3-animations.html
how can i change the vars and the script, so the script would be for every combination of any “settings” + “home” div? Like a vertical menu and on each “home” div the combined “settings” div slides in.
<script>
function goTo(targetPanelId) {
var home = document.getElementById('home');
var settings = document.getElementById('settings');
if (targetPanelId === 'settings') {
home.className = 'slide left out';
settings.className = 'slide left in';
} else {
home.className = 'slide right in';
settings.className = 'slide right out';
}
return false;
}
</script>
Here’s my code, hope this is what you wanted:
jsfiddle
HTML
JS
Note the removed p tags, I had to make the anchor the whole width of its parent with a span for the button style, because else 100% x-translation would not be the complete animation.