我带来了关于jQuery的另一个问题:
所以我有这个代码:
$(document).ready(function(){
$(this).click(function(){
$("#block1").animate({width:7em,height:7em});
$("#block2").animate({width:7em,height:7em});
$("#block3").animate({width:7em,height:7em});
$("#block4").animate({width:7em,height:7em});
$("#block5").animate({width:7em,height:7em,function(){
$(this).animate({width:20em,height:20em,top:4em,left:8em});
});
});
});
应该得到一些“后贴”形状的盒子
1:将所有盒子放回原来的位置和尺寸
2:弹出原始位置进入屏幕中间,同时放大时点击..
你知道为什么这不起作用吗? (我不希望css悬停,但如果还有另一种方法可以通过CSS执行此操作,我可以使用它!)
答案 0 :(得分:3)
$(document).ready(function(){
$(this).click(function(){
$("#block1").animate({width:"7em",height:"7em"});
$("#block2").animate({width:"7em",height:"7em"});
$("#block3").animate({width:"7em",height:"7em"});
$("#block4").animate({width:"7em",height:"7em"});
$("#block5").animate({width:"7em",height:"7em"},function(){
$(this).animate({width:"20em",height:"20em",top:"4em",left:"8em"});
});
});
});
1)在第7行“$(”#block5“)中缺少右括号.animate({width:”7em“,height:”7em“'}',function(){”
2)你还需要包含jquery文件
3)动画你需要给出比元素当前高度和宽度更大的高度和宽度来看效果,即超过7em,就像你已经给出了7em
4)我在jsFiddle链接
中找到的元素也没有ID上述所有要点均基于您提供的链接http://jsfiddle.net/q5RwE/2/
答案 1 :(得分:1)
更改您的代码
.animate({宽度: “7em”,高度: “7em”});