Home > Web Front-end > Front-end Q&A > What to do if jquery load js is lost

What to do if jquery load js is lost

藏色散人
Release: 2023-02-09 10:39:52
Original
1870 people have browsed it

jquery load js missing solution: 1. In the js script of a.html, use load to load all b.html to make the js script in b.html take effect. The code is like "$(' selector').load('b.html',function(){......})"; 2. Put a.html and b.html in the same folder, and the css will take effect.

What to do if jquery load js is lost

The operating environment of this tutorial: Windows 10 system, jquery3.2.1 version, DELL G3 computer

What should I do if jquery load js is lost?

When JQuery uses the load method to load an external div, css and js are invalid.

Problem:

An html page a.html In the js script, use the $('selector').load method to load the content in another html page b.html. The css and js in b.html are invalid.

Solution 1:

Step one: In the js script of a.html, use load to load all b.html, so that the js in b.html The script will take effect, that is:

$('selector').load('b.html',function(){
......
})
Copy after login
Copy after login

Step 2: Add the css link in b.html to the tag of a.html, and the css will take effect.

Solution two:

Step one (same as above): In the js script of a.html, use load to load all b.html, so that b.html The js script in will take effect, that is:

$('selector').load('b.html',function(){
......
})
Copy after login
Copy after login

Step 2: Put a.html and b.html in the same folder, and the css will take effect.

Key points:

a.html and b.html are in the same folder, load the entire html directly, and js will take effect; css will take effect automatically;

a.html and b.html are not in the same folder, load the entire html directly, and the js will take effect; the css link is invalid in b.html and must be added to a.html to take effect.

Recommended learning: "jQuery Video Tutorial"

The above is the detailed content of What to do if jquery load js is lost. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template