Animate only with IDs not next elements
Hi,
i'm using this function at the moment:
-
$(document).ready(function(){
$("a#animate").click().toggle(function(){$(this).next().animate({Height:'hide',opacity:'hide'},'slow');},function(){$(this).next().animate({Height:'show',opacity:'show'},'slow');});
});
How can i change this to work with different DIV IDs and not only the next element? Sooner i did this with something like function change(id){...} and <a href=# onclick=change()>change</a>
I mean something like this:
-
$(document).ready(function(id){
$("a#animate").click().toggle(
function(){$(id+'_content').animate({Height:'hide',opacity:'hide'},'slow');},
function()$(id+'_content').animate({Height:'show',opacity:'show'},'slow');});
});
HTML:
-
<div><a href="#" id="animate">open/close</a></div>
<div id="block1_content" style="background:yellow;height:500px">Test</div>
<div><a href="#" id="animate">open/close</a></div>
<div id="block2_content" style="background:yellow;height:500px">Test</div>
<div><a href="#" id="animate">open/close</a></div>
<div id="block3_content" style="background:yellow;height:500px">Test</div>
Thanks!
nbg