简体   繁体   中英

Add javascript to separate file .js

I added a javascript to html file to match password,

<script>function checkPassword(form) {```**code**```}</script>
<html><form onSubmit = "return checkPassword(this)"><html>

it works fine. But i want to separate the javascript to a .js file. Is there any way to do it??

You can do this by adding a src attribute to your script tag and pointing it towards your js file.

<script src="./yourJsFile.js"></script>
<html><form onSubmit = "return checkPassword(this)"><html>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM