I have viewed this answer jquery append external html file into my page
And was wondering if it applied to my situation.
I have a page that includes another, can I use the jquery .html() to inject html on the included page?
<html><body>some text <includedpage.html></body></html>
If includedpage.html contains a div <div class="demo-container"> Can I inject as such:? $('div.demo-container')
.html('<p>All new content. <em>You bet!</em></p>');
Will this work?
Yes, it should work, assuming that when you inspect the DOM after including the file,
has become
jQuery operates on the current DOM structure of the page, including other changes that jQuery makes to it (such as inserting and removing elements, i.e. using
.html()method), not the page as it was loaded from the server.