Reputation: 1137
I know that I can change the value of a web page using following code in Java script
<p id="demo"></p>
<script>
document.getElementById("demo").innerHTML = "Hello World!";
</script>
I want to assign a new value for my p tag which get value from another web page other web site
Upvotes: 0
Views: 2020
Reputation: 1384
If you're using jQuery on your page, you can solve this in one line with the jQuery.load() function like this:
$( "#demo" ).load( "yourURL #other-content" );
Where #demo
is the p tag on your page, and #other-content
is the p tag on the other page.
More documentation here: http://api.jquery.com/load/
Note: for this to work both pages have to be on the same domain.
Upvotes: 1