February 1, 201115 yr Could anyone point me in the direction of a menu (probably javascript?) that changes a main image when the menu items are hovered over and goes to a link when clicked? I would like the nav menu on the right hand side that changes the image shown in the left side on rollover. I'd like to be able to have either rollover images for the nav items, or just use css to display a different background image on hover/active. Thanks Edited February 2, 201115 yr by ffmedia
February 2, 201115 yr Could anyone point me in the direction of a menu (probably javascript?) that changes a main image when the menu items are hovered over and goes to a link when clicked? I would like the nav menu on the right hand side that changes the image shown in the left side on rollover. I'd like to be able to have either rollover images for the nav items, or just use css to display a different background image on hover/active. Thanks This is easy, You need to include the jquery lib into your webpage. The script $(document).ready(function() { //First image $('#link1').click(function() { $('#div').fadeIn(300); $('#div').html('<img src="image1.png" alt="">'); } //Second image $('#link2').click(function() { $('#div').fadeIn(300); $('#div').html('<img src="image2.png" alt="">'); } } Display Window: <div id="div"></div> Menu Button: <a id="link1" href="#">Link 1</a> <a id="link2" href="#">Link 2</a> This has not been tested but should change the background image of the div onlick
February 2, 201115 yr Author Thanks Shaun, I would like the main div content to change when the menu items are hovered over, is it as straightforward as changing .click to .hover? $(document).ready(function() { //First image $('#link1').click(function() { $('#div').fadeIn(300); $('#div').html('<img src="image1.png" alt="">'); } to $(document).ready(function() { //First image $('#link1').hover(function() { $('#div').fadeIn(300); $('#div').html('<img src="image1.png" alt="">'); } Then would I just include an href link to the new page so it goes to that page when the menu item is clicked? <a id="link1" href="contact_page.html">Link 1</a> Thanks
February 2, 201115 yr Thanks Shaun, I would like the main div content to change when the menu items are hovered over, is it as straightforward as changing .click to .hover? $(document).ready(function() { //First image $('#link1').click(function() { $('#div').fadeIn(300); $('#div').html('<img src="image1.png" alt="">'); } to $(document).ready(function() { //First image $('#link1').hover(function() { $('#div').fadeIn(300); $('#div').html('<img src="image1.png" alt="">'); } Then would I just include an href link to the new page so it goes to that page when the menu item is clicked? <a id="link1" href="contact_page.html">Link 1</a> Thanks Yes you can do this
February 3, 201115 yr Author I have tried using the script but cannot get it to work. I have applied CSS to #div so make sure it is correctly positioned and large enough to show the images. Dreamweaver shows a syntax error in $('#link2').hover(function() { but i can't see the problem. Also how do I change it so it changes the main image on hover rather than click. Just changing it from .click to .hover doesn't seem to do anything. <script src="js/jquery-1.5.js"></script> <script> $(document).ready(function() { //First image $('#link1').hover(function() { $('#div').fadeIn(300); $('#div').html('<img src="images/viewer.png" alt="">'); } //Second image $('#link2').hover(function() { $('#div').fadeIn(300); $('#div').html('<img src="images/btn_down.jpg" alt="">'); } } </script> Thanks
Create an account or sign in to comment