简体   繁体   English

刷新 <table> 不刷新整个页面的HTML仅Javascript

[英]Refresh <table> HTML without refresh entire page Javascript Only

I would like to know how can i refresh my without refresh the entire page in Javascript 我想知道如何刷新而不用Java刷新整个页面

Exemple of HTML HTML的示例

<table class="list" cellpadding="1" cellspacing="1">
        <thead>
            <tr>
                <td class="checkbox edit"></td>
                <td class="Element sortable" onclick="My.Game.List.sort(223, 'eleemnt');">Element</td>
                <td class="ew sortable" onclick="My.Game.List.sort(223, 'ew');">Pop.</td>
                <td class="distance sortable" onclick="My.Game.RaidList.sort(223, 'distance');">Distance</td>
                <td class="element sortable" onclick="My.Game.List.sort(223, 'element');">Option</td>
                <td class="last sortable" onclick="My.Game.List.sort(223, 'last');">Last</td>
                <td class="action"></td>
            </tr>
        </thead>
        <tbody>
             <tr class="slotRow" id="slot-row-3021">
        <td class="checkbox">
            <input id="slot3021" name="slot[3021]" type="checkbox" class="markSlot check" onclick="My.Game.List.markSlot(223, 3021, this.checked);">
        </td>
        <td class="element">

                <a href="position_details.php?x=59&amp;y=14">Artic</a>
        </td>
        <td class="ew">
            31          </td>
        <td class="distance">
            2.2         </td>
        <td class="Option">
            <div class="icon"><img class="unit u11" alt="My ALt" src="img/x.gif"><span class="MyClass">2</span></div>           </td>
        <td class="last">
                                    <img src="img/x.gif" class="My Class"> // Might Change
                                                <img src="img/x.gif" class="carry full" alt="My Alt // Might Change
                    <a href="berichte.php?id=159141|bb7215c9">18.09.18, 15:26</a> // Change
                    <div class="clear"></div>
                                </td>
        <td class="action">
            <a class="arrow" href="#" onclick="My.Game.List.editSlot(223, 3021, true, 'rallyPoint'); return false;">Éditer</a>
        </td>
    </tr>               
        </tbody>
    </table>

Basicly i would like to refresh the content of all the row of my Table 基本上我想刷新表的所有行的内容

I tried this but it seems not working i don't understand why : 我尝试了这个,但似乎不起作用,我不明白为什么:

JAVASCRIPT CODE : JAVASCRIPT代码:

 setInterval(function() {

                document.getElementsByTagName('table')[0].reload();

                }, 500);

NB : The function is just a timer to refresh the table each 500 ms. 注意:该功能只是一个计时器,每500毫秒刷新一次表。

What is excepted to change : 更改之外的内容:

<tr class="slotRow" id="slot-row-3021">
            <td class="checkbox">
                <input id="slot3021" name="slot[3021]" type="checkbox" class="markSlot check" onclick="My.Game.List.markSlot(223, 3021, this.checked);">
            </td>
            <td class="element">

                    <a href="position_details.php?x=59&amp;y=14">Artic</a>
            </td>
            <td class="ew">
                31          </td>
            <td class="distance">
                2.2         </td>
            <td class="Option">
                <div class="icon"><img class="unit u11" alt="My ALt" src="img/x.gif"><span class="MyClass">2</span></div>           </td>
            <td class="last">
                                        <img src="img/x.gif" class="My Class"> // Might Change
                                                    <img src="img/x.gif" class="carry full" alt="My Alt // Might Change
                        <a href="berichte.php?id=159141|bb7215c9">18.09.18, 15:26</a> // Change
                        <div class="clear"></div>
                                    </td>
            <td class="action">
                <a class="arrow" href="#" onclick="My.Game.List.editSlot(223, 3021, true, 'rallyPoint'); return false;">Éditer</a>
            </td>
        </tr>

Best regards ! 最好的祝福 !

There are a lot of answers to your question. 您的问题有很多答案。

You could simply fix this by replacing the (inner)HTML of the element any time an update takes place. 您可以通过在每次更新时替换元素的(内部)HTML来解决此问题。

Something like HTML : draw table using innerHTML HTML之类的东西:使用innerHTML绘制表格

Messy, but it is the answer to your question. 混乱,但这是您的问题的答案。

Your HTML is not dynamicly updating values, that would be done trough javascript. 您的HTML不会动态更新值,这可以通过javascript完成。 If you are getting your values from a webservice - look into AJAX. 如果您要从Web服务获取价值,请查看AJAX。

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

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