Note that there are some explanatory texts on larger screens.

plurals
  1. POQuick and easy jquery li/div change
    primarykey
    data
    text
    <p>just wondering if someone can help me make this code work properly and be used for multipul li's without declaring each one separately. Is this possible? Basically want to do an background image rollover with the &lt; li > then when hovering over the &lt; li > have a the contents of #show change. Does that make sense? Any clues of help would be much appreciated. </p> <p>Code so far:</p> <p>JQUERY:</p> <pre><code>function switchTo(i) { $('#menu li').css({background:"url(images/1.png) no-repeat top left"}).eq(i).css({background:"url(images/1.png) no-repeat bottom left"}); $('#show div').css('display','none').eq(i).css('display','block'); $('#menu li').css({background:"url(images/2.png) no-repeat top left"}).eq(i).css({background:"url(images/2.png) no-repeat bottom left"}); $('#show div').css('display','none').eq(i).css('display','block'); $('#menu li').css({background:"url(images/3.png) no-repeat top left"}).eq(i).css({background:"url(images/3.png) no-repeat bottom left"}); $('#show div').css('display','none').eq(i).css('display','block'); $('#menu li').css({background:"url(images/4.png) no-repeat top left"}).eq(i).css({background:"url(images/4.png) no-repeat bottom left"}); $('#show div').css('display','none').eq(i).css('display','block'); } $(document).ready(function(){ $('#menu li').mouseover(function(event){ switchTo($('#menu li').index(event.target)); }); switchTo(0); }); </code></pre> <p>HTML:</p> <pre><code>&lt;ul id="menu"&gt; &lt;li&gt;&lt;/li&gt; &lt;li&gt;&lt;/li&gt; &lt;li&gt;&lt;/li&gt; &lt;li&gt;&lt;/li&gt; &lt;/ul&gt; &lt;div id="show"&gt; &lt;div&gt;1&lt;/div&gt; &lt;div&gt;2&lt;/div&gt; &lt;div&gt;3&lt;/div&gt; &lt;div&gt;4&lt;/div&gt; &lt;/div&gt; </code></pre> <p>Thanks again.</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.
 

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