简体   繁体   English

使用JavaScript从一页到div的HTML

[英]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.

相关问题 如何使用javascript将一个html页面上的div内容与另一页面上的div内容更改? - How to change the content of a div on one html page with the contents of a div from another page using javascript? HTML / JavaScript页面跳转到div - Html/javascript page jumping to div 使用 jquery 将整个 html div 从一个页面移动到另一个页面 - move an entire html div from one page to another using jquery 如何使用javascript从外部html页面加载div? - how to load a div from an external html page using javascript? 通过 JavaScript 将变量从一个 html 页面传递到另一个页面 - Passing Variable through JavaScript from one html page to another page 将javascript变量从一个html页面传递到另一页面 - Passing javascript variable from one html page to another page 如何在同一 html 页面上的 javascript 中显示一个 div 并隐藏另一个 div - How to show one div and hide another div in javascript on same html page 如何在JavaScript中将值从一个html页面传递到另一个页面? - How to pass value from one html page to another in JavaScript? 如何将javascript / jquery函数从一个HTML页面传递到另一HTML页面 - How to pass a javascript/jquery function from one html page to another 如何将动态变量从一个 html 页面传递给 javascript? - How to pass a dynamic variable from one html page to javascript?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM