I updated your script https://jsfiddle.net/scf0ma4c/5/ , since your code was a bit discharged.
In pure JavaScript, instead of using:
card.toggleClassName('flipped');
which does not exist at all, you should use:
+=card.className
If you are using jQuery:
$("#card").toggleClass("flipped");
simplified.
I believe using:
window.addEventListener('DOMContentLoaded', init, false);
completely pointless since you want the flip to appear on click, so I deleted it.
Look at the violin for more.
source share