Using jQuery to do an onClick div refresh

纵饮孤独 提交于 2020-01-10 15:37:38

问题


This should work right? I have not a clue as to why it's not. I have to be doing something wrong.

<div id="randomdiv">text</div>
    <a id="refresh">click</a>

    <script>
    $(function() {
      $("#refresh").click(function() {
         $("#randomdiv").load("index.php")
      })
    })
    </script>

回答1:


What happen if you do this?

<a id="refresh" href="#">click</a>

<script>
    $(function() {
      $("#refresh").click(function(evt) {
         $("#randomdiv").load("index.php")
         evt.preventDefault();
      })
    })
</script>


来源:https://stackoverflow.com/questions/1401603/using-jquery-to-do-an-onclick-div-refresh

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!