0
我想創建一個名爲「按鈕」的新跨度類。當點擊「按鈕」時,它應該運行jQuery並翻轉.front
而不是「按鈕」。我嘗試過:$('.button').bind("click",function() {
,但它隻影響按鈕,而不是.front
。jQuery:如何使新的「按鈕」運行此功能
HTML:
<span class="button">Run!</span>
的jQuery:
$(document).ready(function(){
$('.front').bind("click",function() {
// $(this) point to the clicked .front element (caching it in elem for speed):
var elem = $(this);
// data('flipped') is a flag we set when we flip the element:
if(elem.data('flipped'))
{
// If the element has already been flipped, use the revertFlip method
elem.revertFlip();
// Unsetting the flag:
elem.data('flipped',false)
}
else
{
// Using the flip method defined by the plugin:
elem.flip({
direction:'tb',
speed: 350,
onBefore: function(){
// Insert the contents of the .back div (hidden from view with display:none)
// into the clicked .front div before the flipping animation starts:
elem.html(elem.siblings('.back').html());
}
});
// Setting the flag:
elem.data('flipped',true);
}
});
});
謝謝!試過這個,但elem.revertFlip();然後不起作用。 –
好的,上面已經更新了,你能解釋一下你想做什麼嗎? –
我想'運行!'在翻轉divs。例如:'
Hello World!
Run!
I am back
Run!