【发布时间】:2023-03-19 04:12:01
【问题描述】:
我正在尝试使用一些简单的 jquery 隐藏一个按钮。 我试图将 jquery.js 文件放在与 html 页面相同的文件夹中,但这会产生 404 错误,因为它正在服务器上而不是我的本地计算机上查找 jquery.js 文件。
我以为我会使用 CDN,但这又不起作用,在控制台中我没有看到任何对 CDN 的请求,就像我将它指定为本地文件时一样。
有人能指出我正确的方向吗?
<html>
<body>
<script src="jquery.js"></script>
<script>
$("#vlan_text").hide();
</script>
<div class="content-section">
<!-- ## form method must be POST for button click action-->
<form method="POST" action="">
<div class="input-group mb-3">
<div class="input-group-prepend" id="test">
<span class="input-group-text">Gi1/0/</span>
</div>
<input type="text" class="form-control" id="port_in" name="port_input" aria-label="Port Number">
</div>
<input class="btn btn-info" type="submit" id="run_int" name="sh_run_int" value="Show interface configuration">
<div class="well">
<!-- ## the <pre> tags specify preformatted text-->
<pre> {{ show_run_int }} </pre>
</div>
<div class="input-group mb-3" id="vlan_div">
<input type="text" class="form-control" id="vlan_text" name="vlan_input" aria-label="VLAN">
</div>
</div>
</form>
<body>
</html>
【问题讨论】:
-
尝试使用文件 public_html/something/something/jquery.js 的完整路径更新:您编写的脚本将在此时触发,因此您应该将其包装在 jQuery(document).ready(function (){ //脚本 });原因是该脚本触发时 DOM 尚未准备好