jquery - Viewing HTML of external pages -


what have far this:

<!doctype html> <html> <head>     <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js">     </script>     <script>     $(document).ready(function(){         $("button").click(function(){             alert($("p").html());         });     });     </script> </head> <body>     <button>return content of p element</button>             <p>test text</p> </body> </html> 

what display content of page. have html file looks this:

<html> <head> </head> <body>     <p>this text</p> </body> </html> 

how go viewing page's html?

if alert part testing , you're trying grab element page 2 , display contents on page 1, can use $.load().

if on page 1 had:

<p id="page1paragraph"></p> <script>     $(document).ready(function() {         $('#page1paragraph').load('page2url.htm #page2paragraph');     }); </script> 

then page 2 contained:

<p id="page2paragraph">text</p>

it make ajax call page contents, , if specify element after url, element's content. code place contents of paragraph tag on page 2 page 1's paragraph tag.

there plenty of examples in jquery docs: http://api.jquery.com/load/


Comments

Popular posts from this blog

ios - UICollectionView Self Sizing Cells with Auto Layout -

node.js - ldapjs - write after end error -

DOM Manipulation in Wordpress (and elsewhere) using php -