Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The relationship between the hovered thing and that animated thing looks a bit random so you'll probably have to use a simple mapping table for that.</p> <pre><code>var id_map = { '2': 'two', '4': 'one', '5': 'three', '6': 'four' }; $('#2, #4, #5, #6').hover( function() { $('#' + id_map[this.id]).stop().animate({opacity: 1}, 600); }, function() { $('#' + id_map[this.id]).stop().animate({opacity: 0}, 600); } ); </code></pre> <p>You could also put the <code>id_map</code> on the source elements using data attributes. The HTML would look something like this:</p> <pre><code>&lt;div id="2" data-target="two" &gt;...&lt;/div&gt; &lt;div id="4" data-target="one" &gt;...&lt;/div&gt; &lt;div id="5" data-target="three"&gt;...&lt;/div&gt; &lt;div id="6" data-target="four" &gt;...&lt;/div&gt; </code></pre> <p>And the jQuery:</p> <pre><code>$('#2, #4, #5, #6').hover( function() { $('#' + $(this).data('target')).stop().animate({opacity: 1}, 600); }, function() { $('#' + $(this).data('target')).stop().animate({opacity: 0}, 600); } ); </code></pre> <p>If you attach a class to the <code>#2</code>, <code>#4</code>, ... elements then you can simplify the selector:</p> <pre><code>$('.someClass').hover( function() { $('#' + $(this).data('target')).stop().animate({opacity: 1}, 600); }, function() { $('#' + $(this).data('target')).stop().animate({opacity: 0}, 600); } ); </code></pre> <p>BTW, using all numeric <code>id</code> attributes is <a href="https://stackoverflow.com/q/70579/479863">a bad idea</a>, they should begin with a letter.</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. 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.
    3. 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