Home > Web Front-end > JS Tutorial > Examples of using JavaScript code in HTML code_javascript tips

Examples of using JavaScript code in HTML code_javascript tips

WBOY
Release: 2016-05-16 16:33:47
Original
1041 people have browsed it

<script></script> tag

To use JavaScript in HTML, you need to use the <script></script> tag and define the type attribute value as text/javascript, as shown in the previous alert pop-up prompt box example:

Copy code The code is as follows:


Usually JavaScript code alone is meaningless. JavaScript code is generally used in conjunction with HTML code, because JavaScript was originally created to make up for the shortcomings of HTML. Here is an example of JavaScript code and HTML code used together:

Copy code The code is as follows:






Image and text content



Usually, JavaScript code (<script></script> tag) is placed within the tag. For more details, please refer to "What is JavaScript code placed in HTML? place? 》.

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