Home > Web Front-end > JS Tutorial > Detailed introduction to inline and external calls of js

Detailed introduction to inline and external calls of js

零下一度
Release: 2017-07-21 17:32:19
Original
2249 people have browsed it

The inline and external calls of js are introduced in detail. Let’s take a look at them below.


If the above code (part of the code that implements the carousel image) is written inline in HTML, it will not work. An exception will occur. But if it is placed in an external js file and called in the head of html, an exception will occur (no error will be reported, but the carousel logic will be abnormal).

Solution: Do not use the global variable $inBox, but use $(".out>.in") directly. That is, replace the $inBox on lines 20 and 31 with $(".out>.in"). The logic is correct.


##Update

Solution two: The external js remains unchanged. When quoting in html, add defer="defer" to delay execution.

You can read another essay for the specific principles.

Solution 3: The external js remains unchanged. In HTML, just quote it at the end of the body.

The above is the detailed content of Detailed introduction to inline and external calls of js. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
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
Latest Issues
What are JavaScript hook functions?
From 1970-01-01 08:00:00
0
0
0
What is JavaScript garbage collection?
From 1970-01-01 08:00:00
0
0
0
c++ calls javascript
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template