日期:2014-05-16 浏览次数:20452 次
$(document).ready(function(){
$("div").click(function(){
if ( $(this).hasClass("protected") )
$(this).animate({height:300},"slow");
.animate({width:300},"slow");
.animate({height:100},"slow");
.animate({width:100},"slow");
});
});
------解决方案--------------------
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$("div").click(function(){
if($(this).hasClass("protected"))
{
$(this).animate({ height: 300 }, "slow").animate({ width: 300 }, "slow").animate({height:100},"slow").animate({ width: 100 }, "slow");
}
});
});
</script>
<style type="text/css">
.protected
{
background: #98bf21;
height: 100px;
width: 100px;
position: relative;
}
</style>
</head>
<body>
<div id="box" class="protected">
</div>
<div>dddd</div>
</body>
</html>