Reputation: 1725
Does anyone know how to load content into a div of external HTML page with jQuery?
Using $('#divname').html("content")
only seems to be able to access div
elements of the HTML page where the script is in.
Upvotes: 1
Views: 10855
Reputation: 1725
Found it! This is what I needed:
I thought I didn't matter that it was a child-parent relationship as long they were in the same domain, but apparently it does.
Thanks for the responses!
Upvotes: 1
Reputation: 171669
You can use load()
to load all content , or target specific content from remote page into an element in local page. load()
is an AJAX method. Do a little research on AJAX
$('#myDiv').load('remotePageUrl')
Or to only get part of the remote page
$('#myDiv').load('remotePageUrl #remotePageID')
API Reference: http://api.jquery.com/load/
Upvotes: 1
Reputation: 2438
If I understand correctly you want to change the content of a DIV of an external page like for example an iframe?
If so, this can't be done with simple jQuery due to security reasons
Upvotes: 3