S. Yeaman
S. Yeaman

Reputation: 13

How to change menu image when hovering over different links?

Let me start of by saying that I am new to this. I have some code from a template that I am using. On the menu drop down there is a list of the links to other pages and next to it is an image. What would I need to add to make the image change to another image when you hover over each of the links?

Here is the code.

<li class="menu-item-has-children megamenu">
    <a href="#">
        <span class="link-icon"></span>
        <span class="link-txt">
            <span class="link-ext"></span>
            <span class="txt">
                Equipment
                <span class="submenu-expander">
                    <i class="fa fa-angle-down"></i>
                </span>
            </span>
        </span>
    </a>
    <ul class="nav-item-children">
        <li>
            <div class="container megamenu-container">
                <div class="vc_row row megamenu-inner-row bg-white p-0">
                    <div class="container ld-container">
                        <div class="row ld-row">

                            <div class="megamenu-column col-md-3 py-md-3 px-md-4">
                                <div class="megamenu-column-inner pl-md-4 py-md-4">
                                    <ul class="lqd-custom-menu reset-ul font-size-15 lh-2 ltr-sp-025 font-weight-medium">
                                        <li>
                                            <a href="#"><i class="fa fa-angle-right mr-2"></i>Vertical Cartoners</a>
                                        </li>
                                        <li>
                                            <a href="#"><i class="fa fa-angle-right mr-2"></i>Horizontal Cartoners</a>
                                        </li>
                                        <li>
                                            <a href="#"><i class="fa fa-angle-right mr-2"></i>Pre Made Pouch Machines</a>
                                        </li>
                                        <li>
                                            <a href="#"><i class="fa fa-angle-right mr-2"></i>Case Packers</a>
                                        </li>
                                        <li>
                                            <a href="#"><i class="fa fa-angle-right mr-2"></i>Rigid Container Fillers</a>
                                        </li>
                                        <li>
                                            <a href="#"><i class="fa fa-angle-right mr-2"></i>Carton Sleeve Wrappers</a>
                                        </li>
                                    </ul>
                                </div><!-- /.megamenu-column-inner -->
                            </div><!-- /.megamenu-column -->

                            <div class="megamenu-column col-md-3 bg-cover bg-center" data-responsive-bg="true">
                                <img class="invisible" src="./img/equipment/vertical-cartoner.jpg" alt="Megamenu Image">
                            </div><!-- /.megamenu-column -->


                        </div><!-- /.row ld-row -->
                    </div><!-- /.container ld-container -->
                </div><!-- /.vc_row -->
            </div><!-- /.megamenu-container -->
        </li>
    </ul>
</li>

Upvotes: 1

Views: 1585

Answers (2)

Libra
Libra

Reputation: 2595

I would use scripting for this kind of thing

$(document).ready(function(){
  $('#op1').hover(function(){
    $('#image').css('background-image','url("https://via.placeholder.com/150.png?text=op1")')
  });
  $('#op2').hover(function(){
    $('#image').css('background-image','url("https://via.placeholder.com/150.png?text=op2")')
  });
  $('#op3').hover(function(){
    $('#image').css('background-image','url("https://via.placeholder.com/150.png?text=op3")')
  });
  
});
#image{
  background-image: url("https://via.placeholder.com/150");
  border: 1px solid black;
  width: 150px;
  height: 150px;
}

#op1, #op2, #op3{
  padding: 5px;
  cursor: pointer;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div id="image"></div>
<div id="op1">hover for op1</div>
<div id="op2">hover for op2</div>
<div id="op3">hover for op3</div>

Upvotes: 1

bron
bron

Reputation: 1548

Find this in your css stylesheet

.megamenu .link-icon {
  ...
}

Add the next lines right after it for a mouse-over effect. Sorry for the dots. For reason that your current css is unknown it is not possible to give the full solution.

.megamenu > a:hover .link-icon {
  ...
}

Upvotes: 0

Related Questions