开发者

Can I make jQuery's load(); appear slowly?

jQuery code:

$(document).ready(function() {
  $("#post_submit").click(function(event) {
      event.preventDefault();
    $("#show").load("post.php", {
      submit: $("#post_submit").val(),
      title: $("#title").val(),
      body: $("#body").val(),
      tag开发者_如何学JAVAs: $("#tags").val()
    });
  });
});

This works fine, and the information is displayed in without the page reloading (yay), but it's not very smooth. I was wondering how I could make it appear slowly, like $(div).show("slow"); or $(div).toggle("slow").


The way to do this would be to load the new content into a hidden container. Then, chain a show('slow') to the end of the load event.

As shown in the jQuery documentation, load returns the jQuery object, so it can be chained with other events.

Something along the lines of

$("#show").hide();
$("#show").load("post.php", {
  submit: $("#post_submit").val(),
  title: $("#title").val(),
  body: $("#body").val(),
  tags: $("#tags").val()
}).show("slow");
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜