javascript - 如何在单击另一个时隐藏CSS

标签 javascript css

我想在不使用 jquery 的情况下单击绿色箭头时隐藏黑色箭头

我的 fiddle : http://jsfiddle.net/t5Nf8/195/

html:

<div class="arrow-down"></div>
<div class="arrow-up"></div>

CSS:

.arrow-down {
    position: absolute;
    /*display: none;*/
    left: 1.5px;
    top: 6px;
    z-index: 1;
    width: 0;
    height: 0;
    border-left: 8px solid transparent;
    border-right: 8px solid transparent;
    border-top: 8px solid #0ef2c4;
    cursor: pointer;
}
.arrow-up {
    border-color: transparent transparent black;
    border-style: dashed dashed solid;
    border-width: 0px 8.5px 8.5px;
    position: absolute;
    left: 1.5px;
    top: 14px;
    z-index: 1;
    height: 0px;
    width: 0px;
}

js:

$('.arrow-up').click(function {
    $('.arrow-down').hide();
});

请大家帮忙

最佳答案

$('.arrow-down').click(function(){
             $('.arrow-up').toggle();       
   });

$('.arrow-up').click(function(){
             $('.arrow-down').toggle();       
   });
  1. You had a syntax error in your Code after function you should have () which you missed in your Code
  2. I Have used toggle so that it shows and hides but you can use hide alone if you want.

DEMO

关于javascript - 如何在单击另一个时隐藏CSS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30124565/

相关文章:

javascript - Facebook Messenger 复选框插件未呈现

javascript - illustrator 自动映射到 imagemap?或者,还有更好的方法?

CSS Z-index 滑动图像

html - BootStrap 怎么可以反转div 的顺序?

html - 如何让浏览器以与内联 css 相同的优先级处理文件中的 css?

javascript - jQuery 在单击时对元素应用过渡

javascript - 谷歌浏览器说无法读取未定义的属性 "calculator"- 计算器是函数名称

javascript - CSS 如何在全屏模式下禁用 Microsoft Edge 媒体控件?

javascript - 如何用javascript仅替换字符串中最后一次出现的数字?

html - 固定导航栏出现问题