Reputation: 183
I try to use transform image (arrow up and down) with jQuery.
It turn upside down but not back when I click again.
HTML
<div class="question">
<h3>Headline</h3>
<p>Paragraph</p>
<span></span>
</div>
JS
$('.question').click(function () {
$(this).find('span').css("transform", "rotateX(180deg)");
});
Upvotes: 0
Views: 89
Reputation: 1726
You're adding the property over and over so it's not going to work. Instead, you could check if the property exists and add or remove it.
For example:
$('.question').click(function() {
var arrow = $(this).find('span');
if (arrow.css("transform") == "none") {
arrow.css("transform", "rotateX(180deg)");
} else {
arrow.css("transform", "none");
}
});
Upvotes: 3