这是我的CSS:如何在点击时显示跨度?
.faqBlock{
margin-bottom:2em;
}
.faqBlock>span{
margin-bottom: 40px;
}
.faqBlock h2{
padding-bottom: 5px;
border-bottom: 1px solid #cf5630;
margin: 0px auto 10px auto;
font-size: 1.33em;
}
.faqBlock .faq{
margin: 1em auto 1em auto;
display:flex;
flex-flow:column;
line-height: 1.2em;
font-size: 1.2em;
}
.faq p{
border-bottom: 1px solid rgba(123,26,29,0);
}
.faqBlock .faqA{
display:none;
transition: all 0.5s ease;
line-height: 1.2em;
max-width: 800px;
margin: 0px auto 1em 20px;
}
这是我的HTML代码:
<div id="FAQQBlock">
<div id="Service" class="faqBlock">
<span>
<h2 class="OldStandard inlineBlock">What You Get When You Order from Epicured</h2>
<span class="faqQABlock">
<span class="faq pointer inlineBlock OldStandard">
<p>Do I have to cook your food myself?</p>
</span>
<span class="faqA inlineBlock OpenSansLight">
<p> Nope! Our chefs have that part covered.</p>
</span>
</span>
**这个跨度是很多人的一个跨度,我有超过30的问题是我想这个JavaScript,它通常工作,但在这种情况下,我的跨度没有工作,任何人都可以看到我在做什么写? 这里是我的javascript:
<script>
$('.faq').click(function() {
$(this).next().toggle();
});
</script>
我想,当我点击“难道我......” “没有。”似乎
也许你缺少关闭? – kurumkan
如果您在**之后添加缺少的标记并执行脚本**,那么DOM中的'.faq'元素可用,这将工作 – Andreas
您可以通过https://validator.w3.org/#validate_by_input快速检查您的标记 – kurumkan