简体   繁体   中英

how to pass a “a href click” into jquery

i am trying to put a pagination page into jquery. example.html?id=foo&get=23

i would like to pass the get= into the jquery script so that i can change the page within the div instead of sending the link to the having the user see example.html?id=foo&get=23, they should only see example.html?id=foo. the rest is done in jquery.

<script >
$(document).ready(function()
 {
 $("#data").load("page.php?ht=<?php print $id; ?>&p=1"  );
 $("#next").click(function(){
  var pageNum = this.id;
  $("#content").load("page.php?ht=<?php print $id; ?>&p=" + pageNum, Hide_Load());
 });
});

<div id="data"> 
    <a href="example.html?id=foo" id="next">page1</a> 

</div> 

Why not modify the anchor

$('#next').attr("href","example.html?id=45");

After every click on the page?

Make sure you use a live click handler, and not just a click handler, because you are creating the #next element after the page loads.

$("#next").live('click', function(){  //etc.

Documentation for .live()

It matches the current selector now and in the future (ie if the elements are created dynamically).

you need something like this:

$(document).ready(function(){
  $("#next").click(function(){
      $.post('your_script_to_get_values.php',
         { page: "1" },
         function(data) {
         $('#content').html(data);
       });
     });
  });  

最简单的方法是使用会话变量。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM