Milan Kumar
Milan Kumar

Reputation: 77

Hover effect on one producing css change in another element

Here is the code:

<ul id="gn-menu" class="gn-menu-main">
            <li class="gn-trigger"> 

            <a class="gn-icon gn-icon-menu">
            <div class="hamburger hamburger--arrow"> 
                <div class="hamburger-box">
                  <div class="hamburger-inner"></div>
                </div>
            </div>
            </a>

                <nav class="gn-menu-wrapper gn-open-part">
                    <div class="gn-scroller">
                    <ul class="gn-menu">
                            <li><a class="gn-icon" id="calendar" href="http://remindbuddy.com/main.php">Calendar</a>

                            </li>

                            <li>
                                <a class="gn-icon self" href="http://remindbuddy.com/self.php">Add For Self</a>
                            </li>
                            <li><a class="gn-icon events" href="http://remindbuddy.com/events.php">Events</a></li>
                            <li><a class="gn-icon view" href="http://remindbuddy.com/contacts.php">View Contacts</a></li>
                            <li>
                                <a class="gn-icon add" id="toggle">Add Contact</a>
                                <ul id="panel" style="display:none">
                                    <li><a href="http://remindbuddy.com/professional.php" <?php if($_SESSION['pro']==0){echo 'style="pointer-events: none;"';}?>>Professional</a></li>
                                    <li><a href="http://remindbuddy.com/personal.php">Personal</a></li>
                                </ul>
                            </li>

                            <li><a class="gn-icon profile" href="http://remindbuddy.com/profile.php">Profile</a></li>

                        </ul>
                    </div><!-- /gn-scroller -->
                </nav>
            </li>



                            <li class="pageTitle"><a href="#"class="title">Profile</a></li>

        </ul>

         <span class="left" id="calendarTool">Calendar</span>

What I want is that, for hover on li#calendar to change css property of span#calendarTool. I have tried:

 #calendar:hover #calendarTool, 
 #calendar:hover + #calendarTool, 
 #calendar:hover ~ #calendarTool

But nothing seems to work.How to get this done in the given scenario.

Thanxx in advance!!

Upvotes: 0

Views: 202

Answers (1)

Derek Story
Derek Story

Reputation: 9583

#calendar is not a sibling nor a parent of #calendarTool so you will not be able to leverage css to handle this. This will require JS/Jquery or a restructure of html so that #calendarTool is a sibling to or nested under #calendar

Quick Jquery example: JS Fiddle

$('#calendar').on('mouseover', function() {
    $('#calendarTool').css('background', 'blue');
});

$('#calendar').on('mouseout', function() {
    $('#calendarTool').css('background', 'transparent');
});

Upvotes: 1

Related Questions