刷新div并避免刷新刷新div中的span / div

时间:2017-02-28 10:21:32

标签: javascript jquery

我有一个div刷新工作,但是可以避免在刷新的div中刷新DIV / SPAN吗?

<script type="text/javascript">
    $(document).ready(function(){
      readings();
    });

    function readings(){
        $('#readingss').load('test_update.php', function(){
           setTimeout(readings, 1000);
        });
    }
</script> 

<div id="readingss">
<span>I dont want this span to be refreshed</span>

<?php include('test_update.php'); ?>
</div>

1 个答案:

答案 0 :(得分:0)

只需使用额外的包装

<script>
    $(document).ready(function(){
      readings();
    });

    function readings(){
        $('#test_update_wrapper').load('test_update.php', function(){
           setTimeout(readings, 1000);
        });
    }
</script>

<div id="readingss">
    <span>I dont want this span to be refreshed</span>
    <div id="test_update_wrapper">
        <?php include('test_update.php'); ?>
    </div>
</div>