weixin_33694172 2015-01-07 07:23 采纳率: 0%
浏览 33

淡入和淡出div标签

I have 2 div tag.If i click div with class adm, emp div want to get blur.After I clicked emp div It back to its own state and adm div will get blur.Now blured div doesn't back to its original state.

I attached html and jquery code.

jquery
  <script>
$(document).ready(function(){
  $(".adm").click(function(){
  $(".emp").fadeTo("slow",0.15);
   if($(".adm").fadeTo(0.15))
    $(".adm").fadeIn();
  });
$(".emp").click(function(){
$(".adm").fadeTo("slow",0.15);
 if($(".emp").fadeTo(0.15))
  $(".emp").fadeIn();
 });
});

 html 
 <div class="adm">
  ...
 </div>
 <div class="emp">
  ...
 </div>

enter image description here

enter image description here

If I click employer employee will blur. after I clicked employee It doesn't back to its original state.now It should appear as third imageenter image description here

  • 写回答

3条回答 默认 最新

  • weixin_33720186 2015-01-07 07:31
    关注

    use this, you don't need if statements

    $(".adm").click(function(){
       $(".emp").fadeTo("slow",0.15);
       $(".adm").fadeTo("slow",1);
      });
    
    $(".emp").click(function(){
     $(".adm").fadeTo("slow",0.15);
     $(".emp").fadeTo("slow",1);
     });
    

    working demo http://jsfiddle.net/243qgkn1/1/

    评论

报告相同问题?