For the following HTML:
<li id="li1">
<div id="card-container">
<div id="card">
<div class="front">
<img id="track_image" src="image.jpg" />
</div>
<div class="back">
<div id="controls">
<audio controls></audio>
</div>
</div>
</div>
</li>
I have the following CSS, which will flip it on hover.
#card-container:hover .back {
-webkit-transform: rotateX(0deg);
}
#card-container:hover .front {
-webkit-transform: rotateX(-180deg);
}
But I want to change it so the flip instead happens on a click, I've attached a click listener and am trying this code below but it doesn't do anything
function click(evt, listElementId) {
var listElement = document.getElementById(listElementId);
var front = listElement.getElementsByClassName("front")[0];
front.style.webkitTransition = "rotateX(-180deg)";
var back = listElement.getElementsByClassName("back")[0];
back.style.webkitTransition = "rotateX(0deg)"
What should the JavaScript be to achieve the same as the CSS is doing?