开发者

Need help to get the bodycontent using javascript or jquery

I have page i want replace body content with some second page body content.From the second page response text how to i w开发者_JS百科ill get the body content to replace the existing body content.

please help to me do this.

Thanks , In advance, Raja.


jQuery's load() function will do the trick:

$(function(){
    $("#something").load("/path/to/page2.php body");
});

Where #something is a jQuery selector of the element you want the data to load into, /path/to/page2.php is a relative URL to the page you want to load and body is the element on the page you want to load into the element. Information on how to use the function is available from load at jQuery API.

Ad@m


$(body)[0]

But why are you doing this, rather than just replacing the content ( in a div with a class )


I am not sure if I understood you well, but if all you are trying to do is to set a page body element with the response you have got from ajax, then that should work:

document.body.innerHTML = ajaxRequest.responseText;


Well with jquery you could do something like this:

  $('body').load('otherpage.html body');

This would clear the body of your html and load the body from otherpage.html


$('body').html('your new content goes here')
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜