I’m trying to load only a div from a page using .load(), but as I am using ‘this.href’ as the page url I’m unsure how I can get just the div from that page.
Heres my code, I want to retrieve a div with id of ‘playerForm’. Currently its returning the whole page.
$(document).ready(function() {
$(".arrow a").click(function(event) {
$("#nominatedPlayer").load(this.href + '#playerForm');
event.preventDefault();
});
});
You need to give the selector a context of the loaded page. To do this provide some sort of html as the second parameter in the selector.
This will still load the entire page, but will select out the div’s html that you want