Implement local refresh with Jquery.load load page _jquery

Source: Internet
Author: User
Because the beginning does not understand jquery, always want to use Jquery.load method load new page, in order to achieve local refresh, the results found in the page loaded in with the original separate page is not the same, the style is gone, and then checked on the Internet, found a solution, this is someone else's answer:

Yes, if you do not filter out some content, direct loading, will make the page confusing, such as the new page also exists <body> tags, loading in, a page will exist two <body> tags are not standard HTML. This is specified in the Jquery.load () function. Normally loaded pages need to redefine CSS styles and add JS events based on the elements of the loaded content. Like what:
Original page a.html:
Copy Code code as follows:

<body>
<div id= "Container" ></div>
</body>The page b.html by load:
<style>.page-li {font-size:12px;color:blue}</style>
<body>
<div id= "Page" >
<ol class= "Page-li" >
<li>234123</li><li>341234</li><li>41234</li><li>412de34</li>
</ol>
</div>
</body>
Load the Jquery.load () of the call in the original page a.html, and then redefine the Page-li style on the original page:
Added load (), CSS's original page:
<style>.page-li {font-size:12px;color:green}</style>
<body>
<div id= "Container" ></div>
<script type= "Text/javascript" >
$ (function () {
$ ("#container"). Load ("b.html #page", Null,function () {alert ("Loaded Successfully")});
});
</script>
</body>

I hope it will help you.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.