jquery - 单击更改背景颜色

时间:2016-12-05 06:15:47

标签: javascript jquery html css

假设文档中有4个标签,我希望单击时背景变为白色,但是当我单击另一个标签时,前一个标签应该恢复为默认值(不使用添加类或删除类)

screenshot of page

https://s25.postimg.org/kb1m0re0f/screenshot_9.png

<header> 
     <label for="slide_trigger1">
        <i class="fa fa-dot-circle-o" aria-hidden="true"></i>
    </label> 
     <label for="slide_trigger2"> 
        <i class="fa fa-dot-circle-o" aria-hidden="true"></i>
     </label>  
      <label for="slide_trigger3">
         <i class="fa fa-dot-circle-o" aria-hidden="true"></i> 
      </label>  
      <label for="slide_trigger4"> 
         <i class="fa fa-dot-circle-o" aria-hidden="true"></i>  
      </label> 
</header>

<script>    
    $(document).ready(function(e) { 
        $('label').click(function() {  
            $(this).css({"background":"#fff","color":"green","border-radius":"100%" }); 
        });
    });
</script>

0 个答案:

没有答案