使用 Javascript 按钮刷新 DIV

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/12407368/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-23 07:54:28  来源:igfitidea点击:

Refresh DIV With Javascript Button

javascript

提问by Noel Chenier

Creating an APP in dreamweaver. How do I make it so a particular DIV will reload/refresh when the user clicks a button.

在 Dreamweaver 中创建一个 APP。当用户单击一个按钮时,我如何使它成为一个特定的 DIV 将重新加载/刷新。

回答by Wearybands

Consider You have a button with id refresh, and the div your want to reload has id div. Once your click on the button it will load the div with the following JQuery

考虑您有一个带有 id refresh 的按钮,并且您要重新加载的 div 具有 id div。单击按钮后,它将使用以下 JQuery 加载 div

 <input type='button' name ='click me' id="refresh" /

 <script>
   $(function() {
     $("#refresh").on("click", function() {
        $("#mydiv").load("index.html")
        return false;
    })
  })
</script>

回答by Aelios

In Jquery

在jQuery中

 <button id="MyButton">Refresh</button>

$(document).ready(function () {
     $("#myButton").on("click", function () {
        $("#div").load("index.php")
     });
});

回答by mast0r

Here is a simple example of how to reload the text in a DIV element:

以下是如何在 DIV 元素中重新加载文本的简单示例:

http://www.w3schools.com/jquery/jquery_ajax.asp

http://www.w3schools.com/jquery/jquery_ajax.asp