After loading a page with Jquery. load, there is no page confusion in the style, and jquery. load Loads

Source: Internet
Author: User

After loading a page with Jquery. load, there is no page confusion in the style, and jquery. load Loads

Because I didn't understand Jquery at first, I always wanted to use jquery. load Method to load a new page, to achieve partial refresh, The results found that the loaded page is different from the original separate page, the style is gone, and then checked on the internet, the solution was found, which was answered by others:

Yes. If some content is not filtered out, loading it directly will make the page messy. For example, a new page also has a <body> tag. After loading it, two <body> tags on a page are nonstandard HTML. This is specified in the jquery. load () function. Generally, you need to redefine the CSS style and add js events based on the elements of the loaded content. For example:

Source Page a.html:

<Html> 

Load the called jquery. load () in the.html of the original page, and then redefine the page-li style on the original page:

Added load (), css's original page:

<Html> 

Hope to help you


Hello, how can I solve the problem of jquery loading another page with jquery?

Yes. If some content is not filtered out, loading it directly will make the page messy. For example, a new page also has a <body> tag. After loading it, two <body> tags on a page are nonstandard HTML. This is specified in the jquery. load () function. Generally, you need to redefine the CSS style and add js events based on the elements of the loaded content. For example:
Source Page a.html:
<Html>
<Head> <title> <Body>
<Div id = "container"> </div>
</Body> Page B .html:
<Html>
<Head> <title> <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 called jquery. load () in the.html of the original page, and then redefine the page-li style on the original page:
Added load (), css's original page:
<Html>
<Head> <title> <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>
Hope to help you

How can I solve js failures of pages loaded by using load in jquery?

You have to add this code to the load event ..

$ ("Id"). load (function (){
$ (". Close"). click (function (){
$ (". Detail"). hide ();
});

});

Related Article

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.