homework
homework

Reputation: 5087

Using jQuery to do an onClick div refresh

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>

Upvotes: 8

Views: 82963

Answers (1)

marcgg
marcgg

Reputation: 66436

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>

Upvotes: 18

Related Questions