我有这个点击事件,第一次单击使图像和 div 变大,第二次单击我想为图像添加翻转效果,第三次单击使 div 和图像再次变小
//CLICK EVENT-------------------------------------------------------------------------------------------------------
$(this).toggle(function()
{
makes div and image bigger
},
function() //2nd function for toggle
{
var margin =$(".image1").width()/2;
var width=$(".image1").width();
var height=$(".image1").height();
$(".image2").stop().css({width:'0px',height:''+height+'px',marginLeft:''+margin+'px',opacity:'0.5'});
flip_image(this);
},
function() //3rd function for toggle
{
Makes div and image smaller
function()
{
rotateByAmount(indexPointer, this); //reset rotation
});
});
//END CLICK EVENT-------------------------------------------------------------------------------------------------------
我试图修改函数flip_image,所以当第二次点击发生时$(".image1").click(function()
会自动运行`? 这可能吗?
function flip_image(thisImage)
{
$(".image1").click(function(){
$(this).stop().animate({width:'0px',height:''+height+'px',marginLeft:''+margin+'px',opacity:'0.5'},{duration:500});
window.setTimeout(function() {
$(".image2").stop().animate({width:''+width+'px',height:''+height+'px',marginLeft:'0px',opacity:'1'},{duration:500});
},500);
});
$(".image2").click(function(){
$(this).stop().animate({width:'0px',height:''+height+'px',marginLeft:''+margin+'px',opacity:'0.5'},{duration:500});
window.setTimeout(function() {
$(".image1").stop().animate({width:''+width+'px',height:''+height+'px',marginLeft:'0px',opacity:'1'},{duration:500});
},500);
});
}