pardeep pardeep - 3 years ago 210
Ajax Question

jQuery's ajax code to load new pages, but I want to get only the html of a div

HTML Code :

<div id="content"></div>


success: function(data){

I want to get only the
HTML of $('div#content') on another page
. How to do it?

Answer Source

Here you go with a solution

At a single point of time, single page will rendering into the browser. So, you can't find the previous page HTML content using JavaScript/ jQuery into another page.

For that you need to use localStorage.

Page 1 HTML

<div id="contentToCopy">

Page 1 JavaScript/jQuery

localStorage.setItem('copiedContent', $('#contentToCopy').html());

Page 2 HTML

<div id="contentToPaste"></div>

Page 2 JavaScript/jQuery


Hope this will help you.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download