Show/hide

how can I show and hide images with jQuery. Currently I am using:

<script>

$("a.M").click(function () {
$("p.M").fadeToggle();
$("p.W").hide("slow");
});
$("a.W").click(function () {
$("p.W").fadeToggle();
$("p.M").hide("slow");
});
</script>

That shows and hides but when I click the button (a href) twice the image changes to the correct one on the first click, but on the second click it disappears. Any ideas on how not to have it completely disappear on the second click? Thanks

It would do that, because you are using fadeToggle(). On the first click, it wasn’t visible, so it goes from not visible to visible. On the second click, it is visible, so it is going from visible to not visible.

If you want it to always be present (no matter how often they click the link), you want to use .show() or .fadeIn() instead of .fadeToggle()

Thank @cpradio, worked great!

Thank you @cpradio, worked great!