简体   繁体   English

嵌套DIV-防止刷新内部DIV

[英]Nested DIVs - Prevent inner DIV from refresh

I am currently refreshing a div as below. 我目前正在刷新div,如下所示。

Main.php Main.php

    <script type="text/javascript">
    var auto_refresh = setInterval(
    function ()
    {
    $('#load_me').load('ajax.php').fadeIn("slow");
    }, 10000); // autorefresh the content of the div after
               //every 10000 milliseconds(10sec)
    </script>

However the page ajax.php has a number of DIV's that should not get refreshed. 但是,页面ajax.php包含许多不应刷新的DIV。 Is there a way to do this? 有没有办法做到这一点? That is, prevent specific DIV's from being refreshed at any cost (with their IDs). 即,防止不惜任何代价(使用其ID)刷新特定DIV。

The reason why this is required is, the DIV has text boxes which are getting refreshed when typing text. 之所以需要这样做,是因为DIV的文本框在键入文本时会刷新。

You could always select what elements to refresh, but doing the opposite and leaving elements out will be more complicated, especially if those elements are nested within elements that should be refreshed etc. 您始终可以选择要刷新的元素,但是相反的操作和将元素留在外面会更加复杂,特别是如果这些元素嵌套在应刷新的元素中等。

var to_refresh = ['id1', 'id2', 'id3'];

var auto_refresh = setInterval(function () {
    $.each(to_refresh, function(_,id) {
        $('#'+id).load('ajax.php #'+id).fadeIn("slow");
    });
}, 1000);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM