javascript - Trying to filter non-hovered elements with jquery -


i have image gallery. trying go lets hovered image maintain styling properties background (non-hovered images, should say) filter grayscale.

this first project , trying push myself. making mistakes learning each one. appreciated.

html:

<section id="image-gallery">             <div class="container">             <div id="imageboxing" class="disciplines">             <img src="images/martial-arts-banner/boxing.png">             <div class="imagetext">             <h3>boxing</h3>             </div>             </div>              <div id="imagekb" class="disciplines">             <img src="images/martial-arts-banner/kickboxing.png">             <div class="imagetext">             <h3>kickboxing</h3>             </div>             </div>              <div id="muaythai" class="disciplines">             <img src="images/martial-arts-banner/muaythai.png">             <div class="imagetext">             <h3>muaythai</h3>             </div>             </div>              <div id="wrestling" class="disciplines">             <img src="images/martial-arts-banner/wrestling.png">             <div class="imagetext">             <h3>wrestling</h3>             </div>             </div>              <div class="clear"></div>              </div>         </section> 

jquery:

$(document).ready(function() {      $(".disciplines img").hover(function(){         var images = $(".disciplines img");         $(this).toggleclass("active-image");         $(this).css("cursor", "pointer");         $(this).next().find('h3').slidetoggle();         if (images.not(".active-image") {             $(images).css("filter", blur("20px"));          }         }); 

you have below:-

$(document).ready(function() {    $("#image-gallery img").hover(function(){ // on hover of image        $(this).toggleclass("active-image");        $(this).css("cursor", "pointer");        $(this).parent().css({"filter": ""}); //remove it's parent  filter css        $('img').not($(this)).parent().css({"filter":'blur(5px)'}); //add filter css othe images parent-div apart thr current clicked-one    }, function () { //when hover-out        $('.disciplines').css({"filter": ""}); //remove filter css div    });  });
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>  <section id="image-gallery">      <div class="container">      <div id="imageboxing" class="disciplines">      <img src="https://ae01.alicdn.com/kf/htb1dizjkfxxxxa_xfxxq6xxfxxxs/closed-type-boxing-helmet-head-protector-for-taekwondo-karate-tai-mma-muay-thai-kickboxing-competition-training.jpg_50x50.jpg">      <div class="imagetext">      <h3>boxing</h3>      </div>      </div>        <div id="imagekb" class="disciplines">      <img src="http://www.days-gym.com/wp-content/uploads/2015/11/days-gym-website-logo.png">      <div class="imagetext">      <h3>kickboxing</h3>      </div>      </div>        <div id="muaythai" class="disciplines">      <img src="https://i.pinimg.com/favicons/50x/ded1fa7e09a93f576a8dc1060fbf82f7e63076e47a08abd0cf27887f.png?ca1416448b5d5bfb6c7465ba2cb5e0d4">      <div class="imagetext">      <h3>muaythai</h3>      </div>      </div>        <div id="wrestling" class="disciplines">      <img src="https://iawrestle.files.wordpress.com/2017/06/screen-shot-2017-06-14-at-10-35-09-am.png?w=50&h=50&crop=1">      <div class="imagetext">      <h3>wrestling</h3>      </div>      </div>        <div class="clear"></div>        </div>  </section>


Comments

Popular posts from this blog

neo4j - finding mutual friends in a cypher statement starting with three or more persons -

php - How to remove letter in front of the word laravel -

minify - Minimizing css files -