我實際上有一些CSS類更改後的函數有問題。CSS類更改後jQuery函數將無法工作
這是我的代碼。
<html>
<head>
<title>jQuery Animate Test</title>
<style>
.animatebox { width: 300px; margin: auto; height: 50px; background: grey; position: absolute; bottom: 250; padding-left: 10px;}
.hiddenstuff { opacity: 0; }
.boxtitle { font-size: 18px; font-weight: 100;}
.clear { clear: both;}
.arrow_up { float: right; margin: 7px 0 0 125px; padding-right: 10px;}
.arrow_down { float: right; margin: 7px 0 0 125px; padding-right: 10px;}
p {margin: 15px 0 0 0;}
</style>
<script src="jquery-1.8.2.js"></script>
</head>
<body>
<h1>Animate Test</h1>
<div id="content">
<div class="animatebox">
<img class="arrow_up" height="35px" src="arrow_up.png"><p class="boxtitle">Lala Box</p>
<div class="clear"></div>
<p class="hiddenstuff">Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata </p>
</div>
</div>
<script>
$(function() {
$('.arrow_up').click(function(){
$('.arrow_up').attr('src',"arrow_down.png");
});
$('.arrow_up').click(function() {
$('.arrow_up').addClass('arrow_down');
});
$('.arrow_up').click(function() {
$('.arrow_up').removeClass('arrow_up');
});
});
$(".arrow_up").click(function() {
$('.animatebox').animate ({
height: '250px'
}, 200);
});
$(".arrow_up").click(function() {
$('.hiddenstuff').animate ({
opacity: '1'
}, 200);
});
$(".arrow_up").click(function() {
$('.boxtitle').animate ({
fontSize: '28px',
fontWeight: '700'
}, 200);
});
$(".arrow_down").click(function() {
$('.animatebox').animate ({
height: '50px'
}, 200);
});
$(".arrow_down").click(function() {
$('.hiddenstuff').animate ({
opacity: '0'
}, 200);
});
$(".arrow_down").click(function() {
$('.boxtitle').animate ({
fontSize: '18px',
fontWeight: '100'
}, 200);
});
</script>
</body>
</html>
點擊了按鈕,一旦它改變爲「arrow_down」之類,但對於降動畫功能則不會工作後?!? :/
UPDATE
$("body").on("click", ".arrow_up", function() {
$('.arrow_up').attr('src',"arrow_down.png");
$('.arrow_up').addClass('arrow_down');
$('.arrow_up').removeClass('arrow_up');
$('.animatebox').animate ({
height: '250px'
}, 200);
$('.hiddenstuff').animate ({
opacity: '1'
}, 200);
$('.boxtitle').animate ({
fontSize: '28px',
fontWeight: '700'
}, 200);
});
$("body").on("click", ".arrow_down", function() {
$('.arrow_down').attr('src',"arrow_up.png");
$('.arrow_down').addClass('arrow_up');
$('.arrow_down').removeClass('arrow_down');
$('.animatebox').animate ({
height: '50px'
}, 200);
$('.hiddenstuff').animate ({
opacity: '0'
}, 200);
$('.boxtitle').animate ({
fontSize: '18px',
fontWeight: '100'
}, 200);
});
對不起,前幾天用jquery啓動了:/ – Basti