Show / Hide Divs using jQuery
Is there an easier way to write the code below?
I have 3 divs on my page 'Hello1', 'Hello2' and 'Hello3'. 'Hello2' and 'Hello3' are hidden by default. I also have 3 links that each anchor to the above divs.
Clicking on a link should show the associated div but hide the rest.
Here is my code...
-
<script>
$(document).ready(function(){
jQuery.fx.off = true;
$(".show1").click(function () {
$("#hello1").show("slow");
$("#hello2, #hello3").hide("slow");
});$(".show2").click(function () {
$("#hello2").show("slow");
$("#hello1, #hello3").hide("slow");
});
$(".show3").click(function () {
$("#hello3").show("slow");
$("#hello2, #hello1").hide("slow");
});
});
</script>
Thanks in advance for your help.
Many thanks
Craig[/code][/quote]