I did this script. But now i need to convert these id to classes because should I put it in other elements of the page.
card ---> .card
flip ---> .flip
var init = function() {
var card = document.getElementById('card');
document.getElementById('flip').addEventListener( 'click', function(){
card.toggleClassName('flipped');
}, false);
};
window.addEventListener('DOMContentLoaded', init, false);
Can you help me?
SOLUTION :
$(function() {
var card = $('.card');
$('.flip').on( "click", function(){
card.toggleClass('flipped');
return false;
});
});
toggleClassNamefunction anywhere? It's not standard. Also, it would be better to actually amend the HTML source directly to achieve this.