Reputation: 1397
I'm trying to use the following code to load an external page into a div:
$("a.btn").click(function(){
$("div#cart_load").load("*url_here*");
});
The problem is, I have multiple links (a.btn) in a page; each with different URL (e.g. http://myurl.com/product/ID) corresponding to different product.
How do I make the load function to automatically get the URL from each link?
Upvotes: 0
Views: 668
Reputation: 630587
You can use the href
property of the anchor you're cliking on, like this:
$("a.btn").click(function(e) {
$("#cart_load").load(this.href);
e.preventDefault(); //stop the browser from following the link
});
Upvotes: 3