[英]Why do I have to rename my javascript file to get my new functions to work
I recently added this function to my .js file for my website: 我最近将此功能添加到我的网站的.js文件中:
function toggleActive() {
$("#terminalLabel").addClass("active");
}
for: 对于:
<input id='terminal' class='hidden' type='checkbox' placeholder='Terminal Option' name='terminal[0][]'>
<label id='terminalLabel' class='btn btn-default' for='terminal2' onclick="toggleActive()">Terminal Option</label>
I kept getting an uncaught reference error when I would try to activate the function, but didn't know why. 当我尝试激活该功能时,我一直收到未捕获的参考错误,但不知道为什么。
I put the function in script tags to see if it worked, and it did. 我将该函数放在脚本标签中,以查看它是否起作用,并且确实起作用。 I added a different function to the button that was already defined in the same .js file that I made this new function, and that function worked.
我向该新功能所在的.js文件中已定义的按钮添加了一个不同的功能,该功能正常工作。
Then I changed the name of the file from form.js to form1.js and had my site call it up, and then the function just worked. 然后,我将该文件的名称从form.js更改为form1.js,并让我的网站对其进行了调用,然后该函数正常工作了。 Why is this?
为什么是这样?
在谷歌浏览器中,按F12键,然后按设置图标(如齿轮一样锁定),并在常规下选中禁用缓存选项(您需要打开开发选项以使其处于活动状态),然后右键单击刷新图标并单击清除缓存,然后单击清除缓存。您也可以在网址末尾添加?_ = 1,它会显示为新版本,并在您进行更改时增加数字。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.