Ich habe einen div und einen Knopf.Wie kann man eine Slide-Up-Animation auf einem dynamischen Element hinzufügen?
mit einem Klick auf die Schaltfläche ich bin ein anderes div anhängen. nach dem Anhängen der zweiten div möchte ich Folie bis zum ersten div hinzufügen und rutschen mit jquery-Animationsmethode auf den zweiten.
<div class="main">
<div class="user">
<div class="closed_div">
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
</div>
</div>
<button class="addDiv">Add open Div</button>
</div>
Jetzt bin ich Anfügen der neuen div mit folgenden Code
$(document).ready(function(){
$('.addDiv').click(function(){
var html = '<div class="open_div">Lorem Ipsum is simply dummy text of the printing and \n\
typesetting industry. Lorem Ipsum has been the industrys \n\
standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type \n\
specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining \n\
essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, \n\
and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.</div>';
$('.user').append(html);
});
});
und Animation mit Code folgenden
$(".closed_div").animate({height:'100%','opacity':1},1500);
$(".open_div").animate({height:0},1500);
Aber seine nicht funktioniert well.Can Sie mir vorschlagen, was ich tue falsch.
Thnakyou.
Haben Sie versucht, slideUp() und slidedown() anstelle von belebten() setzen? Sieht so aus, als hättest du ein "." vor open_div in $ ("open_div"). animate ({height: 0}, 1500); – JasonB
Ja, ich habe slideUp und slideDown ausprobiert. und ich habe einen fraglichen Punkt verpasst. nicht in echt –
Wenn du das neue div anfügst, möchtest du das alte div durch slideup verstecken und das neue div mit slidedown anzeigen. Recht? –