5 回答 5

4

这应该让你开始:

$(document).on('click', 'a', function(event) {
  event.preventDefault();    // Now the link doesn't do anything
  var href = this.href;      // The link's URL is in this variable
});
于 2012-04-13T23:09:44.497 回答
1

可以做类似的事情

$(document).on('click', '*[href]', function(e) {
   // Whatever you're trying to do
   e.preventDefault();
   return false;
});
于 2012-04-13T23:10:12.190 回答
0
$(document).on('click','a[href]',function(){
    var href = $(this).attr('href');

    $.ajax(href,function(data){
        $(your_container).html(data);
        //data is the HTML returned
        //note that ajax is bound to the
        //same origin policy
        //any request outside your domain won't work
    })

    return false;
});
于 2012-04-13T23:10:57.690 回答
0
<a href="javascript:void(0);">...</a>

然后你可以为这个锚编写脚本。

于 2012-04-13T23:12:25.990 回答
0

这应该这样做:

$("a").click(function(event) {
  event.preventDefault();
  var href = $(this).attr("href");
  $.ajax({
     url: href,
     success: function(data) {
      alert('Load was performed.');
    }
  });
});
于 2012-04-13T23:14:46.267 回答