Note that there are some explanatory texts on larger screens.

plurals
  1. POSimple javascript problem - onMouseOver div background change
    primarykey
    data
    text
    <p>I used <a href="http://mckennedy.org/blog/2009/02/25/javascript-onmouseover-link-change-divs-background-image/" rel="nofollow">this</a> code to make a nav in which onMouseOver, the neighboring div's background changes to a corresponding image. </p> <p>However, I amended the code to reflect the multiple navigation buttons I needed. This is probably where I went wrong. Also, I am working in a ColdFusion environment on Sitemaker CMS. This could also be a problem. </p> <p>Here's the code.</p> <pre><code>&lt;script&gt; function changeStyle1() { document.getElementById('banners').style.backgroundImage = url('images/banners/contractingbanner.jpg'); } function changeStyle2() { document.getElementById('banners').style.backgroundImage = url('images/banners/procurementbanner.jpg'); } function changeStyle3() { document.getElementById('banners').style.backgroundImage = url('images/banners/distributionbanner.jpg'); } function changeStyle4() { document.getElementById('banners').style.backgroundImage = url('images/banners/printingbanner.jpg'); } function changeStyle5() { document.getElementById('banners').style.backgroundImage = url('images/banners/custompacksbanner.jpg'); } function changeStyle6() { document.getElementById('banners').style.backgroundImage = url('images/banners/businessdevelopmentbanner.jpg'); } function changeStyle7() { document.getElementById('banners').style.backgroundImage = url('images/banners/sustainabilitybanner.jpg'); } function changeStyleBack() { document.getElementById('banners').style.backgroundImage = url('images/banners/laundrybanner.jpg'); }&lt;/script&gt; </code></pre> <hr> <pre><code>&lt;div id="banners"&gt; &amp;nbsp; &lt;/div&gt; &lt;ul id="nav"&gt; &lt;li&gt;&lt;a id="contractingservices" href="body.cfm?id=1" onmouseover="changeStyle1()"; onmouseout="changeStyleBack()"&gt;Contracting Services&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a id="procurement" href="body.cfm?id=1" onmouseover="changeStyle2()"; onmouseout="changeStyleBack()" &gt;Procurement &amp;amp; Data Management&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a id="distribution" href="body.cfm?id=1" onmouseover="changeStyle3()"; onmouseout="changeStyleBack()"&gt;Distribution&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a id="printing" href="body.cfm?id=1" onmouseover="changeStyle4()"; onmouseout="changeStyleBack()" &gt;Printing&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a id="laundry" href="body.cfm?id=1"&gt;Laundry&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a id="custompacks" href="body.cfm?id=1" onmouseover="changeStyle5()"; onmouseout="changeStyleBack()" &gt;Custom Packs&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a id="businessdevelopment" href="body.cfm?id=1" onmouseover="changeStyle6()"; onmouseout="changeStyleBack()" &gt;Business Development&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a id="sustainability" href="body.cfm?id=1" onmouseover="changeStyle7()"; onmouseout="changeStyleBack()" &gt;Sustainability&lt;/a&gt;&lt;/li&gt; </code></pre> <p></p> <p>How do I fix this code to make it operational or find another JavaScript or jQuery solution? I've searched and search only to come up with dozens of same-div JS background changers, which can easily be replicated with CSS. </p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    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.
 

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