Reputation: 3888
Forgive me if the answer seems too obvious, I'm really new to jQuery. I'm trying use the Flip! plugin on my webpage, but for some reason, after the user clicks the <li>
the second time, the content isn't reverted, but instead, the same flip function is used, therefore rendering the same result. I want the user to be able to flip back and forth at will. Here is my code:
jQuery
$('.class').click(
function() {
$(this).flip({
direction: 'lr',
content: $('p', this).html(),
speed: 200,
})
},
function() {
$(this).revertFlip()
}
);
html
<ul>
<li class="class">
<span class="image">
<img src="images/jquery-small.png" alt="">
</span>
<p>
<span class="content">blah blah blah</span>
</p>
</li>
</ul>
Upvotes: 1
Views: 2700
Reputation: 126072
.click()
does not take two function references. I think you're looking for .toggle()
(which does):
$('.class').toggle(
function() {
$(this).flip({
direction: 'lr',
content: $('p', this).html(),
speed: 200,
})
},
function() {
$(this).revertFlip()
}
);
(In the example I changed the "content" to make it more obvious that it is working)
Upvotes: 2