[英]HTML from one page to div with javascript
I have a button that, when clicked, gets contents from another page and puts the content from that page in a div
. 我有一个按钮,单击该按钮时会从另一个页面获取内容,并将该页面的内容放入
div
。 The page that it gets the content from has additional code that makes the text fade after it has been displayed. 它从中获取内容的页面还有其他代码,这些代码使文本在显示后消失。 But, when it gets the contents from that page it does not bring over that portion too.
但是,当它从该页面获取内容时,也不会移到那部分。 Is there a way that either in the code, below, or on the page it gets the contents from make the text fade out once it is displayed?
有没有一种方法可以在下面的代码中或页面上从内容中获取内容,使文本一旦显示就淡出?
<script type="text/javascript">
$(document).ready(function(){
$("input[name=buttonup53]").click(function(){
$.ajax({url:"add.php?r=sbt&l=35&t=53&w=1", success:function(result){
$("div[id=up53]").html(result);
}});
});});
</script>
<div id="up53"></div>
<input type="image" name="buttonup53" id="buttonup53" src="button.png" width="25px"></input>
If I have understood correctly you can use a setTimeout in the success callback to make the div fade away. 如果我理解正确,则可以在成功回调中使用setTimeout使div消失。
$.ajax({
url:'',
...
success:function(result){
$("#up53").html(result);
setTimeout(function(){$("#up53").fadeOut('slow');},2000);
}
});
you can use load() method of jquery. 您可以使用jquery的load()方法。 Jquery Load()
jQuery的Load()
$("Div#up53").load("add.php?r=sbt&l=35&t=53&w=1");
怎么样:
$("div[id=up53]").html(result).fadeOut();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.