[英]Why when I try to hide my CSS triangle with jQuery by adding a class does it not work?
I want to hide my CSS triangle which is attached to a div using :before
, and I came across this solution to implement: https://stackoverflow.com/a/11354393/998117我想隐藏使用
:before
附加到 div 的 CSS 三角形,我遇到了这个解决方案来实现: https : //stackoverflow.com/a/11354393/998117
However, my jQuery is not working:但是,我的 jQuery 不起作用:
$(".contact input[type='submit']").click(function(event) {
event.preventDefault();
$(".contact .inner").addClass("hidden");
...
(Yes, it does get called.) (是的,它确实被调用了。)
This is what my CSS/SASS looks like:这是我的 CSS/SASS 的样子:
.contact {
background: #3c6ea5;
color: #fff;
display: none;
height: 500px;
.hidden:before {
display: none;
}
.inner {
margin: auto;
padding-top: 20px;
position: relative;
width: 400px;
&:before {
border: solid;
border-color: #3c6ea5 transparent;
border-width: 14px 16px 0 16px;
bottom: -107px;
content: "";
display: block;
position: absolute;
right: -50px;
}
.hidden:before {
display: none;
}
}
...
Why is it not hiding it?为什么它不隐藏它? What am I doing wrong?
我究竟做错了什么?
Your Sass is off just a little bit, should be:你的 Sass 有点不对劲,应该是:
.inner {
&.hidden:before {
display: none;
}
}
Notice the & before hidden注意隐藏之前的 &
Try below code to solve your problem:尝试以下代码来解决您的问题:
.inner { &:before {
.hidden & { display:none;}}}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.