|
|
|
| В общем делаю с помощью animate.
Есть квадрат, по клику он скрывается до 10 px, еще раз нажимаешь(когда он скрылся) - высота увеличивается до 100 px. Проблема в том, что не знаю как сделать, чтобы это было бесконечно, так как он скрывается, потом раскрывается и все.
Я думаю, что там где-то нужно поставить return false; , хотя и не уверен.
Вот код:
<html>
<head>
<style>
#a {
display: block;
background: red;
width: 100px;
height: 100px;
}
</style>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$("#a").click(function () {
$(this).animate({
"height" : "10px"
}, {duration: "slow", queue: false});
$(this).click(function () {
$(this).animate({
"height" : "100px"
}, {duration: "slow", queue: false});
});
});
});
</script>
</head>
<body>
<div id="a"></div>
</body>
</html>
|
UPDATE
Все, сделал. Вот решение:
<script type="text/javascript">
$(document).ready(function() {
$("#a")
.toggle(function() {
$(this).animate({
"height" : "30px"
}, {duration: "slow", queue: false});
}, function() {
$(this).animate({
"height" : "100px"
}, {duration: "slow", queue: false});
});
});
</script>
|
| |
|
|