【发布时间】:2016-07-29 22:40:49
【问题描述】:
我正在尝试使用我的 Jquery 来隐藏和显示文本,但它不起作用。而且我很肯定这很愚蠢。
这是我的 HTML:
<script src="js/showhide.js"></script>
<script src="js/jquery.min.js"></script>
<div class="container-fluid">
<div class="row">
<div class="col-xs-12 col-md-4">
<button class="btn btntruespeed" id="showdsl6">DSL 6</button>
<p>DSL 6 is perfect for anyone who is a light Internet user. It's perfect for those who only have 1-2 devices in the house, and they go on Facebook, and check and send emails.</p>
</div>
</div>
</div>
还有showhide.js文件:
$(document).ready(function(){
$("p").hide();
$('#showdsl6').click(function(){
$("p").show();
});
});
我不知道出了什么问题,有人可以帮忙吗?谢谢。
【问题讨论】:
-
它就像一个魅力! jsFiddle 要切换吗?或者你的意思是根本不工作?
-
您好,我不知道您的文件 showhide.js 包含什么,但如果您在其中使用 jquery,最好在包含 showhide.js 之前包含 jquery.min.js。我希望这对你有帮助
-
@pedram 不,jsFiddle 运行良好。我不知道断开连接在哪里。
-
@Fender 在我的实时代码中,我用我的 showhide.js 和 jquery.min.js 交换了位置
-
好的@ThomasHutton,它工作正常吗?