MaVe
MaVe

Reputation: 1725

Load content into div of external html page with JQuery

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

Answers (4)

MaVe
MaVe

Reputation: 1725

Found it! This is what I needed:

access div in iframe parent

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

charlietfl
charlietfl

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

DivZero
DivZero

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

Talha Akbar
Talha Akbar

Reputation: 10030

$.get("test.php", function(data){
$("div").html(data);
});

Upvotes: 0

Related Questions