Rebecca Salliss
Rebecca Salliss

Reputation: 23

Jquery show/hide on image click

I simply want to show a div once you click on a image.The code i have used is below:

<td colspan="3" rowspan="7">
        <img title="Vintage Dinner Plate"  onclick="$('dinnerplates').show('fast')"class="masterTooltip" src="images/images/slicevintage_16.jpg" width="110" height="123" alt=""></td>
<div>
<p class="dinnerplates" style="background-color:#69a0d0;">This is my text.This is my text.This is my text.This is my text.This is my text.This is my text.This is my text.</p>

Upvotes: 0

Views: 68

Answers (2)

Jay
Jay

Reputation: 1678

Possibly similar to what you're looking for. Place the script before your </body> and provided you have the jQuery library linked in it should work fine.

<script>
$(".masterTooltip").click(function() {
    $(".dinnerplates").toggle();
});
</script>

UPDATE: http://jsfiddle.net/5xs5vewd/

Upvotes: 1

James
James

Reputation: 442

Your jQuery selector is missing the prefixed "." before the class name.

It should be:

$('.dinnerplates').show('fast')

Upvotes: 2

Related Questions