Read html / text from another html page using jquery

Is it possible to read or extract html / text from another .html page using jquery?

this is what i would like to read and display on another page

<div class="newsItemContent"> <h1 class="title"> heading 1 </h1> content 1 content 1 content 1 content 1 </div> <div class="newsItemContent"> <h1 class="title"> heading 2 </h1> content 2 content 2 content 2 content 2 </div> 

thanks

+1
source share
5 answers

Of course. $. The get () method will do what you want.

+2
source

You can extract from another page using the load method , thus $('#targetElement').load('page.htm #container') .

+4
source

If the page is on the same domain / server, you can try to access it through AJAX

+2
source

You can use ajax for this . Or if it is in another JSONP domain.

0
source

If the second page is within the iframe, you can get something like:

 $('#iframeID').contents().html(); 
0
source

Source: https://habr.com/ru/post/927761/


All Articles