【发布时间】:2018-04-03 09:41:01
【问题描述】:
我有一个为我重新加载表格的函数,但是当我单击重新加载表格时不会执行其中的 JavaScript。它确实令人耳目一新。我只是暂时使用h3点击,因为它很简单。
<script>
function RefreshTable()
{
$( "#calenderTable" ).load( "my-page.html #calenderTable" );
}
$(document).ready(function()
{
$("h3").click(function()
{
RefreshTable();
});
});
</script>
HTML 是
<h3>Refresh Table</h3>
<table class="table" id="calenderTable">
<tr>
<th scope="col">House</th>
<th scope="col">Monday <br><script type="text/javascript">document.write("Hello World");</script></th>
<th scope="col">Tuesday <br><script type="text/javascript">document.write(getDate(2));</script></th>
<th scope="col">Wednsday <br><script type="text/javascript">document.write(getDate(3));</script></th>
<th scope="col">Thursday <br><script type="text/javascript">document.write(getDate(4));</script></th>
<th scope="col">Friday <br> <script type="text/javascript">document.write(getDate(5));</script></th>
</tr>
<tbody>
<tr>
<td class="cal"><a href="#"> 1 </a></td>
<td ></td>
<td ></td>
<td ></td>
<td ></td>
<td></td>
</tr>
</tbody>
</table>
所以第一次加载页面时它会显示“hello world”,但是当我单击刷新时它不再显示。我只是在这个例子中使用 hello world,我真的希望 getDate 函数能够执行并在表格中显示正确的日期。
【问题讨论】:
-
我在您给定的 HTML 中看不到任何
h3标记 -
@AlivetoDie 这不是问题,当我点击它时它会重新加载。
-
我们如何检查?也添加那个 HTML 好友
-
好的,我也添加了 h3 和 table id
标签: javascript jquery html