简体   繁体   English

单独的html文件和javascript文件中的javascript事件处理程序

[英]javascript's event handler in separate html file and javascript file

I want to write javascript's event handler in separate html file and javascript file. 我想在单独的html文件和javascript文件中编写javascript的事件处理程序。 I am in trouble because it does not work if it is the method of reference site. 我很麻烦,因为如果它是参考站点的方法,它将无法正常工作。 Sample Site : https://techacademy.jp/magazine/15062 样本网站: https : //techacademy.jp/magazine/15062

How do I write event handlers in javascript without writing event handlers in html? 如何在不使用html编写事件处理程序的情况下用javascript写事件处理程序? I would like to write it in a way like a sample site. 我想以示例站点的方式编写它。

write code in a separate js file and add on the HTML using <script> file just before </body> 在单独的js文件中编写代码,并在</body>之前使用<script>文件添加HTML

<script type="file/path/name.js"></script>

is that you are asking about? 你在问什么吗?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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