Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Assuming, the shapes array is an array of DOM elements, I think you can use something like this where you set up a hover event handler for each shape and then within each function passed to the hover event handler, you iterate over the shapes array and if it's not the one that you are hovering over, you do the animation.</p> <pre><code> jQuery.each(shapes, function(i) { this.hover(function(event) { var self = this; jQuery.each(shapes, function(index, value) { if (value != self) { $(value).animate({fill: "#fff"}, 500); } }); }, function(event) { var self = this; jQuery.each(shapes, function(index, value) { if (value != self) { $(value).animate({fill: "#555"}, 500); } }); }); }); </code></pre> <p>or it might be cleaner with a local function:</p> <pre><code> jQuery.each(shapes, function(i) { function animateIfNotMe(me, fillValue) { jQuery.each(shapes, function(index, value) { if (value != me) { $(value).animate({fill: fillValue}, 500); } }); } this.hover(function(event) { animateIfNotMe(this, "#fff"); }, function(event) { animateIfNotMe(this, "#555"); }); }); </code></pre> <p><strong>EDIT:</strong> I see you've added actual code now to your question (since I wrote my answer) and shapes isn't an array of DOM objects (it would be nice if you had disclosed that originally) so obviously this code won't work exactly as it is, but hopefully you can get the idea from this code for how you can iterate over all the other shapes and just exclude the current one you are hovering on and you can then adapt it to your particular shapes data structure.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload