【发布时间】:2015-01-25 18:26:02
【问题描述】:
我正在尝试使用一些容器和文本来执行显示/隐藏功能。
当我单击某个容器时,我希望隐藏一段。目前我正在尝试解决当我单击"left" 容器时,"barbertext" 段落会消失。
<p class="hairtext" style="color:red">We are Thairapy, an independent hair <br> and beauty Salon located in the heart<br> of Exeter. At Thairapy, we care about<br> our clients and our main aim is to go<br> that extra mile and look after every <br> one of our happy customers.</p>
<p class="beautytext" style="color:red">Our beautician, Shail Dutt has over<br> 10 years of experience within the beauty<br> industry. Shail is a very dedicated and<br> passionate person, she strives to make<br> her clients feel loved and special. </p>
<p class="barbertext" style="color:red">A decent Mens haircut needn't cost the<br>Earth. We offer top quality Men's haircuts<br> from £7. </p>
<div class="container" id= "left" >
<h1 style="color:white"><a>HAIR</a></h1>
</div>
<div class= "container" id= "center">
<h1 style="color:white"><a>BEAUTY<a/></h1>
</div>
<div class="container" id= "right">
<h1 style="color:white"><a>BARBERS</a></h1>
</div>
</div>
我正在使用的 Javascript 是这样的:
<script>
$(document).ready(function(){
$("#hairtext").click(function(){
$("barbertext").hide();
});
$("#hairtext").click(function(){
$("barbertext").show();
});
});
</script>
如果有人能提供帮助,我将不胜感激。
【问题讨论】:
-
您缺少 .对于 barbertext 类:$(".barbertext").hide();
标签: javascript jquery html show-hide