The mouse does not work in all directions

HTML

<!--DASHBOARD-->
   <li class="always_show">
      <span class="menu_large_item" style="display: none;">
          <a href="/xyz/dashboard">
             <div class="ribbon-body-prof-menu">Dashboard</div>
          </a>
      </span>
      <a class="menu_small_item" href="/dashboard"> V </a>
    </li>
 <!--DASHBOARD-->


<!--PROFILE -->
    <li class="always_show" id="profile_menu_item">  
        <span class="menu_large_item" style="display: none;">
            <a href="/xyz/profile/iprofile/id/3">
                <div class="ribbon-body-prof-menu"> Profile</div>
            </a>
 <!--PROFILE -->
        </span>
        <a class="menu_small_item" class="selected" href="/profile/iprofile/id/3">

<!-- <img src="http://localhost/xyz/public/images/icon-industries.png" alt="Profile" title="Profile" width="12" height="15"> -->
                    N
        </a>
     </li>

Now I want that when I hover over menu_small_item, the part menu_large_itemshows, and when I exit menu_small_item, then the part is menu_large_itemhiding. The same thing happens, but in the case of the last element in my html, when I pull the mouse from the bottom, nothing happens.

JQuery

    $('li.always_show, a.menu_small_item').mouseover(function(){
        $(this).siblings('li.always_show span.menu_large_item').show();
    $(this).siblings('span').children('a').children('div.ribbon-body-prof-menu').show();
});
$('li.always_show span.menu_large_item, .ribbon-body-prof-menu').mouseout(function(){
    $(this).hide();
    $('li.always_show span.menu_large_item').hide();
    $('div.ribbon-body-prof-menu').css('display','none');       
});

I implemented the same on

https://jsfiddle.net/shilpi_jas/nh1n4pcv/ Any help would be appreciated.

+4
source share
2 answers

, HTML + CSS ( ..) - . , , HTML, . no-js, , , , HTML... javascript. , , , , , :

HTML

<ul>
    <li>
        <a class="menu_small_item" href="#">A</a>
        <a class="menu_large_item" href="#">Lorem</a>
    </li>
    <li>
        <a class="menu_small_item" href="#">B</a>
        <a class="menu_large_item" href="#">Ipsum</a>
    </li>
    <li>
        <a class="menu_small_item" href="#">C</a>
        <a class="menu_large_item" href="#">Dolor</a>
    </li>
    <li>
        <a class="menu_small_item" href="#">D</a>
        <a class="menu_large_item" href="#">Sit</a>
    </li>
    <li>
        <a class="menu_small_item" href="#">E</a>
        <a class="menu_large_item" href="#">Amet</a>
    </li>
<ul>

CSS

ul {list-style-type:none;width:100px;}
li {margin-bottom:15px;cursor:pointer;}
li a {display:block;width:85px;padding:5px;text-decoration: none;}
.menu_small_item { color: #b084e9;}
.menu_large_item { display: none;color: #fff;background: #4D356F;box-sizing: border-box;}
li:hover > .menu_small_item {display:none;}
li:hover > .menu_large_item {display:block;}

+1

fadeTo jQuery show hide. mouseout .

fadeTo , , , .

, doc

fadeTo(1, 1) show() fadeTo(1, 0) hide()

+1

All Articles