我试图用一些简单的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>
答案 0 :(得分:0)
尝试下面的代码,并确保您的HTML和JQuery两个文件都在同一目录中。
<html>
<body>
<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>
<script src="jquery.js"></script>
<script>
$("#vlan_text").hide();
</script>
<body>
</html>
答案 1 :(得分:0)
确保标记文件(HTML)和JQuery位于同一目录中或具有正确的脚本路径。
您为什么不关闭身体标签(也许是因为他)?