To prevent the event from spreading to span.expand
elements, you can do the following:
$("span.expand").mouseover(function(e) {
e.stopImmediatePropagation();
});
RECENT UPDATE: The initial use of `stopPropagating` did not achieve the desired result. After considering the user's suggestion, an alternative solution was implemented:
Add two new CSS rules:
.stay-gray a.menu__link {
border-bottom-color: #474E51 !important;
}
.stay-gray, .stay-gray a.menu__link {
color: #474E51 !important;
}
Include the following code at the end of your
jQuery(document).ready(function(){ ...
:
toggleStayGray=function(e){ jQuery(e.target).siblings().toggleClass('stay-gray') };
jQuery('.menu span.expand').mouseover(toggleStayGray).mouseout(toggleStayGray);
By adopting this method:
jQuery(document).ready(function(){
jQuery(".not-front .menu__item.is-expanded.last.expanded span").after("<span class='menu__link nolink expand'> </span>");
jQuery(".front .menu__item.is-expanded.last.ex... (truncated)</answer1>
<exanswer1><div class="answer accepted" i="21920241" l="3.0" c="1392918162" m="1393014476" v="1" a="R3VpbGxlcm1vIEd1dGkmIzIzMztzdGF5">
<p>Why not consider halting the event propagation on the <code>span.expand
components:
$("span.expand").mouseover(function(e) {
e.stopPropagation();
});
UPDATE: Despite trying out 'stopPropagating', it did not produce the intended effect. Thus, in line with the suggestion made by the original poster, we formulated an alternate solution:
Incorporate two additional CSS guidelines:
.stay-gray a.menu__link {
border-bottom-color: #474E51 !important;
}
.stay-gray, .stay-gray a.menu__link {
color: #474E51 !important;
}
Subsequently, append these instructions towards the conclusion of the
jQuery(document).ready(function(){ ...
:
toggleStayGray=function(e){ jQuery(e.target).siblings().toggleClass('stay-gray') };
jQuery('.menu span.expand').mouseover(toggleStayGray).mouseout(toggleStayGray);
Upon employing this method:
jQuery(document).ready(function(){
jQuery(".not-front .menu__item.is-expanded.last.... (truncated)</answer1></answer1>
<exanswer1><div class="answer accepted" i="21920239" l="3.0" c="1392918162" m="1393014476" v="1" a="R3VpbGxlcm1vIEd1dGkmIzIzMztycmV6" ai="806975">
<p>Perhaps you should consider not allowing the event to propagate on the <code>span.expand
elements:
$("span.expand").mouseover(function(e) {
e.stopPropagation();
});
UPDATE: The use of `stopPropagating` did not achieve the desired result. Therefore, following the suggestion provided by the OP, we came up with this alternative solution:
Introduce two additional CSS rules:
.stay-gray a.menu__link {
border-bottom-color: #474E51 !important;
}
.stay-gray, .stay-gray a.menu__link {
color: #474E51 !important;
}
Then add these lines at the end of the
jQuery(document).ready(function(){ ...
:
toggleStayGray=function(e){ jQuery(e.target).siblings().toggleClass('stay-gray') };
jQuery('.menu span.expand').mouseover(toggleStayGray).mouseout(toggleStayGray);
With this approach:
jQuery(document).ready(function(){
jQuery(".not-front .menu__item.is-expanded.last.expanded span").after("<span class='menu__link nolink expand'> </span>");
jQuery(".front .menu__item.is-expanded.last.ex... (truncated)</answer1>
<exanswer1><div class="answer accepted" i="21920239" l="3.0" c="1392918162" m="1393014476" v="1" a="R3VpbGxlcm1vIEd1dGkmIzIzMztycmV6" ai="806975">
<p>Maybe you could try stop propagating the event on the <code>span.expand
elements:
$("span.expand").mouseover(function(e) {
e.stopPropagation();
});
EDIT: stopPropagating
didn't work. So, retaking the idea proposed by the OP, we figured out this solution:
Add two new CSS rules:
.stay-gray a.menu__link {
border-bottom-color: #474E51 !important;
}
.stay-gray, .stay-gray a.menu__link {
color: #474E51 !important;
}
And then add this lines at the end of the
jQuery(document).ready(function(){ ...
:
toggleStayGray=function(e){ jQuery(e.target).siblings().toggleClass('stay-gray') };
jQuery('.menu span.expand').mouseover(toggleStayGray).mouseout(toggleStayGray);
This way:
jQuery(document).ready(function(){
jQuery(".not-front .menu__item.is-expanded.last.expanded span").after("<span class='menu__link nolink expand'> </span>");
jQuery(".front .menu__item.is-expanded.last.expanded span").after("<span class='menu__link nolink expand collapse'> </span>");
jQuery("#block-menu-block-1 ul li li").css({ display: "block" });
jQuery(".not-front #block-menu-block-1 ul li li").css({ display: "none" });
jQuery('#block-menu-block-1 .menu__item.is-expanded').click(function(){
jQuery('#block-menu-block-1 ul li li').toggle('fast');
jQuery( ".menu__item.is-expanded.last.expanded span.menu__link.nolink.expand" ).toggleClass( "collapse" );
});
toggleStayGray=function(e){ jQuery(e.target).siblings().toggleClass('stay-gray') };
jQuery('.menu span.expand').mouseover(toggleStayGray).mouseout(toggleStayGray);
});
When hovering over the span.expand
element, the stay-gray
class is toggled on its siblings, applying new styles to them and their a.menu__link
descendants. The stay-gray
class is toggled off when the mouse leaves.