Jeroen
Jeroen

Reputation: 137

get html from a div and show them on a other page

i am struggling with the following :

I have a html mainpage , on this page i have a column with a "read more"section , so a couple of lines tekst from a news message from a html page called News .

when there is new news , i have to update the "read more"section by hand .

Is it possible with Jquery and ajax to update the "read more"section on page load.

maybe you guys have a better way to do something like this , ore is there some $ code i dont know

hope you can help me

Cheers

Upvotes: 1

Views: 568

Answers (1)

Marcel
Marcel

Reputation: 28087

You can look at loading page fragments using .load(). Depending on your page's markup, something like this on the main page should work.

// Grab the first div in the #news element on
// the news.html page and jam it into #recent
$('#recent').load('/news.html #news div:first');

Demo: jsfiddle.net/SLx9c

Upvotes: 1

Related Questions