so I have a javascript function that changes the class name of a div
function flip (event)
{
var element = event.currentTarget;
element.className = (element.className == 'card') ? 'card flipped' : 'card';
}
How can I make it so my onclick="flip(event)"
can be attached to a button (or preferably an image) and the button will then flip the card instead of just clicking inside the div. So something like
<div id="card" class="card">
<p>
whatever
</p>
<img onclick="flip(event)" src="foo">
</div>
What do I need to change in my javascript function?