php - Reloading only a div, many different possible links -


i'm inexperienced in jquery. did research , found code should allow me reload div of page:

<script>  $(document).ready(function(){   $(".reload").click(function(){     $("#day").load("/some_url #day > *");   });  }); </script> 

as can see reload #day when element of class .reload clicked. problem url. page has many different instances of class, each different url. generated in php such:

echo "<div class=\"reload\"><a href=\"index.php?day=$day\" > $day </a></div>"; 

so i'm no longer sure i'm using correct approach. want when user clicks 1 of links, instead of reloading whole page in link, update #day on current page. each instance of class reload points different link.

try this:

$(".reload a").click(function(event){     event.preventdefault();     var url = $(this).prop('href');     $("#day").load(url + " #day > *"); }); 

fiddle


Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -