开发者

read html/text from another html page using jquery

is it possible to read or extract html/text from a different .html page using jquery?

this what i would like to read and display in a different page

                    <div class="newsItemContent"> 
                      <h1 class="title"> 
                        heading 1
         开发者_如何学JAVA             </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


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


Most certainly. The $.get() method will do what you want.


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


If the second page is within an iframe, you could access it with something like:

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


Yup you can use ajax for this. Or if it's on a different domain JSONP.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜