开发者

Swapping content with jquery and adding fadein effect

开发者 https://www.devze.com 2023-04-12 21:31 出处:网络
Wondering if anyone has an answer to this conundrum? I\'ve got some Jquery working which swaps content within a div when some text is clicked:

Wondering if anyone has an answer to this conundrum?

I've got some Jquery working which swaps content within a div when some text is clicked:

<script type="text/javascript">
  $(document).ready(function() {
  $("#changeText").click(function() {
  $("#textBox").html("<div>This text will be changed to something else. in a div</div>");
 });
});
</script>

<a id="changeText">F开发者_开发问答ind out more</a>
<br />
<div id="textBox"><div>This text will be changed to something else</div></div>

But, when the content is swapped I'd like to be able to fade out the old content and fade in the new. Is there a way of doing this?


$("#changeText").click(function() {
    $("#textBox").children().fadeOut('fast',function(){
       $("#textBox").html("<div>This text will be changed to something else. in    a div</div>").fadeIn('fast');
    });
 });

check here http://jsfiddle.net/vfzcv/1/

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号