Here is the code

<script> $(document).ready(function(){ $('#btn0').click(function(){ $.ajax({ url: "include_page/index.php", cache: false, success: function(html){ $("#content").html(html); } }); }); $('#btn1').click(function(){ $.ajax({ url: "include_page/index.php", cache: false, success: function(html){ $("#content").html(html); } }); }); $('#btn2').click(function(){ $.ajax({ url: "include_page/ru.php", cache: false, success: function(html){ $("#content").html(html); } }); }); $('#btn3').click(function(){ $.ajax({ url: "include_page/stream.php", cache: false, success: function(html){ $("#content").html(html); } }); }); $('#btn4').click(function(){ $.ajax({ url: "include_page/eu.php", cache: false, success: function(html){ $("#content").html(html); } }); }); $('#btn5').click(function(){ $.ajax({ url: "include_page/register.php", cache: false, success: function(html){ $("#content").html(html); } }); }); $('#btn6').click(function(){ $.ajax({ url: "include_page/gifts.php", cache: false, success: function(html){ $("#content").html(html); } }); }); }); </script> 
 <nav id="nav"> <a href="#" id="btn1"> Home </a> <a href="#Teams" id="btn2"> Teams </a> <a href="#Stream" id="btn3"> Stream </a> <a href="#Brackets" id="btn4"> Brackets </a> <a href="#Register" id="btn5"> Register </a> <a href="#Prizes" id="btn6"> Prizes </a> </nav> 

  • Maybe because of the default browser actions ? - RTK
  • offtopic, but your js can be reduced to 8 lines instead of 70 - Alexey Shimansky

2 answers 2

The browser needs to be told to cancel the default actions for clicking on the link. Those. So:

 $('nav a').click(function(e){ e.preventDefault(); }); 

    The second, more suitable for jQuery option

     $('nav a').click(function(e){ //ajax & etc return false; }); 

    Difference preventDefault, stopPropagation and stopImmediatePropagation

    • and how to add hashes? - MininDm