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.
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(){ ...... })
Step 2: Add the css link in b.html to thetag 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(){ ...... })
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!