开发者

Swapping content with jquery and adding fadein effect

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜