У меня есть программа, и она работает хорошо.
Смотри ЗДЕСЬ .
Это код:
<div id="round"></div>
<style>
#round{
position: absolute;
width: 200px;
height: 200px;
border-radius: 50%;
left: 400px;
top: 200px;
background-color: #e1e1e1;
}
</style>
<script src="jquery.js"></script>
<script src="jquery.easing.1.3.js"></script>
<script>
$(document).ready(function(){
$("#round").click(function(){
setInterval(function(){
$("#round").animate(
{height: 250,
width: 150,
top:150,
left: 425},
{duration: 300}
).
animate(
{height: 200,
width: 200,
top:200,
left: 400},
{duration: 300}
);
}, 0);
});
});
</script>
Но когда я меняю "#round" на "this". Это не сработает. Зачем?
(на самом деле это работает, но когда я помещаю их в setInterval (), это не будет работать)
$(document).ready(function(){
$("#round").click(function(){
setInterval(function(){
$("#round").animate(
{height: 250,
width: 150,
top:150,
left: 425},
{duration: 300}
).
animate(
{height: 200,
width: 200,
top:200,
left: 400},
{duration: 300}
);
}, 0);
});
});
изменить на "это", это не будет работать.
$(document).ready(function(){
$("#round").click(function(){
setInterval(function(){
$(this).animate(
{height: 250,
width: 150,
top:150,
left: 425},
{duration: 300}
).
animate(
{height: 200,
width: 200,
top:200,
left: 400},
{duration: 300}
);
}, 0);
});
});