表在Ajax重新加载时丢失CSS样式

时间:2018-12-07 16:02:23

标签: javascript ajax html-table reload

我有一个带有id="example"的表。我还有一个按钮,可以在点击时重新加载表格。

 <button id="refresh-btn">Refresh Table</button>

<script>
$(document).ready(function() {

   function RefreshTable() {
       $( "#example" ).load( document.URL + ' #example' );
   }

   $("#refresh-btn").on("click", RefreshTable);
</script>

单击按钮并重新加载后,表将刷新,但会丢失其CSS样式。 重新加载ajax之前:

重新加载ajax之后:

The link to my table.

感谢您的帮助。

1 个答案:

答案 0 :(得分:-1)

嘿,我希望这可以给您提示:

在刷新为它们设置样式的行上的类之前

Before refresh the classes on the row that style them are there

After Refresh there are no classes so you have to check what your ajax call exactly do

刷新后没有任何类,因此您必须检查ajax调用的确切作用

希望这甚至可以帮助一点点,但是现在您知道问题出在哪里了。