I created a flyout menu using css and called the css class in javascript.The problem is, onmouseover the menu is highlighting and the pop up is coming under the menu when we move the mouse down towards the link the highlighting is not displaying. Please help me in how to get this resolved. -
my JS code :
-
var num, current = false;
-
$('#site_navigation > li.items > a')
-
.hoverIntent(function(e){
-
//Clear out the open subnavs
-
$('.subnav').css('display','none');
-
var $$ = $(this);
-
num = parseInt(($$.parent().attr('id')).substr(4,1));
-
num -= 2;
-
var sel = '#subnav-' + num;
-
-
/*============================TRACE=========================
-
var o = {};
-
o.dir ='IN';
-
o.target = e.target;
-
o.relatedTarget = e.relatedTarget;
-
o.num = num;
-
o.sel = sel;
-
o.id = $$.parent().attr('id').substr(4,1);
-
log(o);
-
//============================END TRACE=====================*/
-
-
-
//1. show the subnav
-
$(sel).css('display','block');
-
-
//2. display the overlay
-
$('#overlay').removeClass('hide');
-
-
//3. Remove existing hover class, Add the 'hover' class to this item
-
rmHover();
-
$$.addClass('hover');
-
-
-
-
},
-
-
-
function(e){
-
//log(e, {'dir':'OUT','target':e.target, 'relatedTarget': e.relatedTarget});
-
//if the closest parent search returns zero, we know we're not in nav box anymore
-
checkAncestor(e,"#nav");
-
});
-
-
function checkAncestor(child, ancestor){
-
child = child.relatedTarget || e.fromElement;
-
var $elem = $(child).closest(ancestor);
-
if($elem.length <1) {
-
hideFlyout();
-
}
-
}
-
//when mouse levaes both top nav and flyout, and doesn't go from one to the other, close the flyout
-
$('#site_navigation, #flyout')
-
.mouseleave(function(e){
-
checkAncestor(e,"#nav");
-
});
-
-
//peg the first two links with a hide function.
-
$('.site_navigation > li:eq(0) a, .site_navigation > li:eq(1) a, .site_navigation > li:eq(2) a, .site_navigation > li:eq(3) a, .site_navigation > li:eq(5) a, .site_navigation > li:eq(6) a, .site_navigation > li:eq(7) a')
-
.mouseenter(function(){
-
hideFlyout();
-
});
-
-
-
function hideFlyout(){
-
rmHover();
-
//Hide the subnavs
-
$('.subnav').css('display','none');
-
//Hide the overlay
-
$('#overlay').addClass('hide');
-
}
-
-
function rmHover(){
-
//Remove the 'hover' class on nav item
-
$('#site_navigation .hover').removeClass('hover');
-
-
}
2 1862
These types of menus are quite popular and really don't need any javascript at all. The javascript complicates things in my opinion and also may run you into problems if a user has javascript turned off.
Post your CSS and HTML and I may be able to help.
Hi Jking,
Thanks a lot for your reply. please find the html, css and Js code. - javascript
-
$(function(){
-
/*Start closure*/
-
/********************/
-
//NAVIGATION This is the flyout menu starting
-
/********************/
-
var num, current = false;
-
$('#site_navigation > li.items > a')
-
.hoverIntent(function(e){
-
//Clear out the open subnavs
-
$('.subnav').css('display','none');
-
var $$ = $(this);
-
num = parseInt(($$.parent().attr('id')).substr(4,1));
-
num -= 2;
-
var sel = '#subnav-' + num;
-
-
/*============================TRACE=========================
-
var o = {};
-
o.dir ='IN';
-
o.target = e.target;
-
o.relatedTarget = e.relatedTarget;
-
o.num = num;
-
o.sel = sel;
-
o.id = $$.parent().attr('id').substr(4,1);
-
log(o);
-
//============================END TRACE=====================*/
-
-
-
//1. show the subnav
-
$(sel).css('display','block');
-
-
//2. display the overlay
-
$('#overlay').removeClass('hide');
-
-
//3. Remove existing hover class, Add the 'hover' class to this item
-
rmHover();
-
$$.addClass('hover');
-
-
-
-
},
-
-
-
function(e){
-
//log(e, {'dir':'OUT','target':e.target, 'relatedTarget': e.relatedTarget});
-
//if the closest parent search returns zero, we know we're not in nav box anymore
-
checkAncestor(e,"#nav");
-
});
-
-
function checkAncestor(child, ancestor){
-
child = child.relatedTarget || e.fromElement;
-
var $elem = $(child).closest(ancestor);
-
if($elem.length <1) {
-
hideFlyout();
-
}
-
}
-
//when mouse levaes both top nav and flyout, and doesn't go from one to the other, close the flyout
-
$('#site_navigation, #flyout')
-
.mouseleave(function(e){
-
checkAncestor(e,"#nav");
-
});
-
-
//peg the first two links with a hide function.
-
$('.site_navigation > li:eq(0) a, .site_navigation > li:eq(1) a, .site_navigation > li:eq(2) a, .site_navigation > li:eq(3) a, .site_navigation > li:eq(5) a, .site_navigation > li:eq(6) a, .site_navigation > li:eq(7) a')
-
.mouseenter(function(){
-
hideFlyout();
-
});
-
-
-
function hideFlyout(){
-
rmHover();
-
//Hide the subnavs
-
$('.subnav').css('display','none');
-
//Hide the overlay
-
$('#overlay').addClass('hide');
-
}
-
-
function rmHover(){
-
//Remove the 'hover' class on nav item
-
$('#site_navigation .hover').removeClass('hover');
-
-
}
-
//This is the flyout menu ending
-
-
/********************/
-
//Left Nav Menu Animation
-
/********************/
-
-
mSetLastItem = function() {
-
$(".leftNavTopics a").removeClass("noDarkBorder");
-
$(".leftNavTopics a:visible:last").addClass("noDarkBorder");
-
}
-
-
mShowMenu = function(mE) {
-
var mThis = $(this);
-
-
if (mThis.next().is(":visible")) {
-
mThis.next().slideUp(200);
-
mThis.removeClass("otherDarkBorder");
-
} else {
-
mThis.parent().siblings().find("a:first").removeClass("otherDarkBorder").next().slideUp(200);
-
mThis.next().slideDown(200);
-
mThis.addClass("otherDarkBorder");
-
mThis.next().children(":last").find("a:first").addClass("otherDarkBorder");
-
}
-
-
mSetLastItem();
-
mE.preventDefault();
-
}
-
-
var mCurrentItem = $(".leftNavTopics .currentItem");
-
-
mCurrentItem.parents("ul").show().prev().addClass("blackArrow");
-
-
if (mCurrentItem.next()) {
-
//mCurrentItem.addClass("darkBorder");
-
mCurrentItem.next().children(":last").find("a:first").addClass("darkBorder");
-
}
-
-
mCurrentItem.next().show().children().find("a:first, a:last").bind("click", mShowMenu);
-
mSetLastItem();
-
-
-
/********************/
-
//SHARETOOL
-
/********************/
-
-
$(".content-up a.shareTool").click(function () {
-
$('.content-up a.shareTool').removeClass("shareTool").addClass('shareToolActive');
-
$('.content-up .page-tools').removeClass("hide");
-
});
-
-
$(".content-up .page-tools li.email a").click(function () {
-
$('.content-up .page-tools .body').animate({ height: "305px" }, 650, function () {
-
$('.content-up .page-tools .body .page-tools-email').fadeIn(200);
-
});
-
-
});
-
-
$(".content-up .cancel-email").click(function () {
-
$('.content-up .page-tools .body .page-tools-email').fadeOut(400, function () {
-
$('.content-up .page-tools .body').animate({ height: "130px" }, 650);
-
});
-
-
});
-
-
$(".content-up .page-tools .close").click(function () {
-
$('.content-up a.shareToolActive').removeClass("shareToolActive").addClass('shareTool');
-
$('.content-up .page-tools').addClass("hide");
-
$('.content-up .page-tools .body .page-tools-email').css({ 'display': 'none' });
-
$('.content-up .page-tools .body').css({ 'height': '130px' });
-
});
-
-
/********************/
-
//ACCORDION
-
/********************/
-
-
// Uncomment to show first block as default
-
$(".accordion h3:first").addClass("active");
-
$(".accordion div:not(:first)").hide();
-
-
//$(".accordion .wrapper").hide();
-
-
$(".accordion h3").click(function () {
-
$(this).next("div.wrapper").slideToggle(400).siblings("div.wrapper:visible").slideUp(400);
-
$(this).toggleClass("active");
-
$(this).siblings("h3").removeClass("active");
-
});
-
-
$("div.article p:last-child").css({ 'margin-bottom': '0px' });
-
-
})
-
-
-
/********************/
-
//Show and Hide radio buttons toogle
-
/********************/
-
function hideDiv(){
-
tag = document.getElementsByTagName("div");
-
for(x=0;x<tag.length; x++){
-
if(tag[x].getAttribute('id').indexOf("choose_") != -1){
-
tag[x].style.display = "none";
-
}
-
}
-
}
-
function view(id){
-
ge = document.getElementById('choose_' + id.value);
-
hideDiv();
-
ge.style.display = "block";
-
}
-
// Start of text size increase
-
var min=8;
-
var max=18;
-
function increaseFontSize() {
-
var p = document.getElementsByTagName('p');
-
for(i=0;i<p.length;i++) {
-
if(p[i].style.fontSize) {
-
var s = parseInt(p[i].style.fontSize.replace("px",""));
-
} else {
-
var s = 12;
-
}
-
if(s!=max) {
-
s += 1;
-
}
-
p[i].style.fontSize = s+"px"
-
}
-
}
-
function decreaseFontSize() {
-
var p = document.getElementsByTagName('p');
-
for(i=0;i<p.length;i++) {
-
if(p[i].style.fontSize) {
-
var s = parseInt(p[i].style.fontSize.replace("px",""));
-
} else {
-
var s = 12;
-
}
-
if(s!=min) {
-
s -= 1;
-
}
-
p[i].style.fontSize = s+"px"
-
}
-
}
-
-
// End of textsize increase
-
-
- html code
-
<div id="nav">
-
<ul id="site_navigation">
-
<li class="items" id="item1"> <a href="page-5.html"> Electricity and <br />
-
gas customers </a> </li>
-
<li class="items" id="item2"> <a> Residential </a> </li>
-
<li class="items" id="item3"> <a href="page-2.html?cur=3"> Your bills and<br />
-
usage </a> </li>
-
<li class="items" id="item4"> <a href="page-2.html?cur=4" class="current"> Your services </a> </li>
-
<li class="items" id="item5"> <a href="page-2.html?cur=5"> Your National <br />
-
Grid </a> </li>
-
<li class="items" id="item6"> <a href="page-2.html?cur=6"> Safety and <br />
-
outages </a> </li>
-
<li class="items" id="item7"> <a href="page-3.html"> Customer <br />
-
support </a> </li>
-
</ul>
-
<!--Start Sub Menu Navigation-->
-
<div id="flyout_container">
-
<div id="flyout">
-
<div class="subnav" id="subnav--1">
-
<div class="inner">
-
<div class="column-1 columns">
-
<h5>You are currently in the Massachusetts electric service site</h5>
-
<div class="lightGraytopborder"></div>
-
<div class="whitespacer"></div>
-
<div>Would like to <a href="page-2.html">Go to the Massachusetts gas service site?</a> <br />
-
<br />
-
or <a href="page-2.html">go to the another regional energy service</a>
-
<div class="whitespacer"></div>
-
<div class="whitespacer"></div>
-
</div>
-
</div>
-
</div>
-
</div>
-
<div class="subnav" id="subnav-0">
-
<div class="inner">
-
<div class="column-1 columns">
-
<h5>You are currently in Residential customers</h5>
-
<div class="lightGraytopborder"></div>
-
<div class="whitespacer"></div>
-
<div>Would you like to go to another destination?
-
<div class="whitespacer"></div>
-
<div class="lightGraytopborder"></div>
-
<ul>
-
<li><a href="#">Business customers</a></li>
-
<li><a href="#">Tradespeople and customers</a></li>
-
<li><a href="#">Energy analysts</a></li>
-
<li><a href="#">Energy supply companies</a></li>
-
<li><a href="#">Regulators</a></li>
-
</ul>
-
</div>
-
</div>
-
</div>
-
</div>
-
<div class="subnav" id="subnav-1">
-
<div class="inner">
-
<div class="column-1 columns">
-
<h5>Your bills and usage</h5>
-
<div class="whitespacer"></div>
-
<div>Lorem ipsum dolor sit amet consectet adipisicing elit,Aliquam elefiend nisi nec mauris ullamcoprepr vitae vulpurtatue tellus aliquet cuarbiter at tortor sit amet<br />
-
<br />
-
<a href="page-2.html">Go now</a></div>
-
</div>
-
<div class="column-2 columns">
-
<ul>
-
<li><a href="page-2.html">View your current bill</a></li>
-
<li><a href="page-2.html">Make a online payment</a></li>
-
<li><a href="page-2.html">Billing and payment options</a></li>
-
<li><a href="page-2.html">Your billing and payment history</a></li>
-
</ul>
-
<p><img alt="Images topnav your service1" src="http://bytes.com/topic/html-css/images/nav-img1.jpg"/><br />
-
<br />
-
Consectetur adipisicing elieiusicing elieiusmod tempor lorem ipsum dolor sit amet lorem<br />
-
<br />
-
<a href="#">Lorem ipsum dolor</a></p>
-
</div>
-
<div class="column-3 columns">
-
<ul>
-
<li><a href="page-2.html">Your usage and cost graph</a></li>
-
<li><a href="page-2.html">Your action plan</a></li>
-
<li><a href="page-2.html">Lower your usage</a></li>
-
<li><a href="page-2.html">Understand your bill and rates</a></li>
-
</ul>
-
<p><img alt="Images topnav your service1" src="http://bytes.com/topic/html-css/images/nav-img2.jpg"/><br />
-
<br />
-
Consectetur adipisicing elieiusicing elieiusmod tempor <br />
-
<br />
-
<a href="#" class="imgBorder">Dolor lorem</a></p>
-
</div>
-
</div>
-
</div>
-
<div class="subnav" id="subnav-2">
-
<div class="inner">
-
<div class="column-1 columns">
-
<h5>Your service</h5>
-
<div class="whitespacer"></div>
-
<div>Intro to services offered in this region orem ipsum dolor sit amet, consectetur adipiscing elit. Fusce lectus metus, interdum ut mollis sit amet, porttitor ac magna. Donec sed mi enim<br />
-
<br />
-
<a href="page-2.html">Go now</a></div>
-
</div>
-
<div class="column-2 columns">
-
<ul>
-
<li><a href="page-2.html">Turn on service</a></li>
-
<li><a href="page-2.html">Turn off service</a></li>
-
<li><a href="page-2.html">Check service availability</a></li>
-
<li><a href="page-2.html">Metering</a></li>
-
</ul>
-
<div class="boldtext">For new customers</div>
-
<div class="whitespacer"></div>
-
<p>Lorem ipsum dolor sit amet, consectetur adipiscing
-
elit. Mauris sed purus nisl. Nulla sed tortor a
-
lectus suscipit tempus ipsum.<br />
-
<br />
-
<a href="#">View all information for new customers</a><br />
-
<br />
-
<a href="#">Request to turn on service</a></p>
-
</div>
-
<div class="column-3 columns">
-
<ul>
-
<li><a href="page-2.html">Convert from oil to gas</a></li>
-
<li><a href="page-2.html">Your supplier options</a></li>
-
<li><a href="page-2.html">Generate your own power</a></li>
-
<li><a href="page-2.html">Other services</a></li>
-
</ul>
-
<div class="boldtext">Moving?</div>
-
<div class="whitespacer"></div>
-
<p>Lorem ipsum dolor sit amet, consectetur adipiscing
-
elit. Mauris sed purus nisl. Nulla sed tortor a
-
lectus suscipit tempus ipsum.<br />
-
<br/>
-
<a href="#">View all information for customers planning
-
to move</a><br />
-
<br />
-
<a href="#">Request to move service</a></p>
-
</div>
-
</div>
-
</div>
-
<div class="subnav" id="subnav-3">
-
<div class="inner">
-
<div class="column-1 columns">
-
<h5>Your account</h5>
-
<div class="whitespacer"></div>
-
<div><a href="page-2.html">Sign in to your Massachusetts electric service account</a></div>
-
</div>
-
<div class="column-2 columns">
-
<ul>
-
<li><a href="page-2.html">Manage your account</a></li>
-
<li><a href="page-2.html">Manage your payment methods</a></li>
-
<li><a href="page-2.html">Manage your alerts email</a></li>
-
</ul>
-
<div class="boldtext">"My house" and "My garage"</div>
-
<div class="whitespacer"></div>
-
<p>Lorem ipsum dolor sit amet, consectetur adipiscing
-
elit. Mauris sed purus nisl. Nulla sed tortor a lectus suscipit tempus ipsum<br />
-
<br />
-
<a href="#">Learn more about account nicknames</a></p>
-
</div>
-
<div class="column-3 columns">
-
<ul>
-
<li><a href="page-2.html">Manage your profile and sign-in</a></li>
-
<li><a href="page-2.html">Add a new account</a></li>
-
</ul>
-
<br />
-
<div class="whitespacer"></div>
-
<div class="boldtext">You are currently in the {Massachusetts electric} service site</div>
-
<div class="whitespacer"></div>
-
<p>Would you like to <a href="#" class="imgBorder">go to the {Massachusetts
-
gas} service site?</a><br />
-
<br/>
-
Or, <a href="#" class="imgBorder">go to another regional service site.</a></p>
-
</div>
-
</div>
-
</div>
-
<div class="subnav" id="subnav-4">
-
<div class="inner">
-
<div class="column-1 columns">
-
<h5>Safety and outages</h5>
-
<div class="whitespacer"></div>
-
<div>Lorem ipsum dolor sit amet,
-
consectetur adipiscing elit.
-
Fusce lectus metus, interdum
-
ut mollis sit amet, porttitor ac
-
magna. Donec sed mi enim<br />
-
<br />
-
<a href="page-2.html">Go now</a></div>
-
</div>
-
<div class="column-2 columns">
-
<ul>
-
<li><a href="page-2.html">Report or check on an outage</a></li>
-
<li><a href="page-2.html">How to report an outage</a></li>
-
<li><a href="page-2.html">Gas interruptions</a></li>
-
</ul>
-
<div class="boldtext">Call before you dig</div>
-
<div class="whitespacer"></div>
-
<p>Lorem ipsum dolor sit amet, consectetur adipiscing
-
elit. Mauris sed purus nisl. Nulla sed tortor a
-
lectus suscipit tempus ipsum.<br />
-
<br />
-
<a href="#">Learn more</a></p>
-
</div>
-
<div class="column-3 columns">
-
<ul>
-
<li><a href="page-2.html">Outage map</a></li>
-
<li><a href="page-2.html">Storm recovery</a></li>
-
<li><a href="page-2.html">Energy safety</a></li>
-
</ul>
-
<div class="boldtext">Carbon monoxide</div>
-
<div class="whitespacer"></div>
-
<p>Lorem ipsum dolor sit amet, consectetur adipiscing
-
elit. Mauris sed purus nisl. Nulla sed tortor a
-
lectus suscipit tempus ipsum<br />
-
<br/>
-
<a href="#" class="imgBorder">Learn more</a></p>
-
</div>
-
</div>
-
</div>
-
<div class="subnav" id="subnav-5">
-
<div class="inner">
-
<div class="column-1 columns">
-
<h5>Customer support</h5>
-
<div class="whitespacer"></div>
-
<div>Lorem ipsum dolor sit amet,
-
consectetur adipiscing elit.
-
Fusce lectus metus, interdum
-
ut mollis sit amet, porttitor ac
-
magna. Donec sed mi enim<br />
-
<br />
-
<a href="page-2.html">Go now</a></div>
-
</div>
-
<div class="column-2 columns">
-
<ul>
-
<li><a href="page-2.html">Get answers to common questions</a></li>
-
<li><a href="page-2.html">Problems with your bill</a></li>
-
<li><a href="page-2.html">Payment assistance programs</a></li>
-
<li><a href="page-2.html">Service problems</a></li>
-
</ul>
-
<div class="boldtext">Service problems may include:</div>
-
<div class="whitespacer"></div>
-
<p>Power outages, energy theft,
-
street lights in need of repair, or
-
metering problems<br />
-
<br />
-
<a href="#">View details</a></p>
-
</div>
-
<div class="column-3 lastTab columns">
-
<ul>
-
<li><a href="page-2.html">Customer rights and responsibilities</a></li>
-
<li><a href="page-2.html">Contact us</a></li>
-
<li><a href="page-2.html">Send us feedback</a></li>
-
</ul>
-
<br />
-
<div class="whitespacer"></div>
-
<div class="boldtext">Report a gas emergenc</div>
-
<div class="whitespacer"></div>
-
<p>[insert local gas emergency module
-
- no links, only informational]</p>
-
</div>
-
</div>
-
</div>
-
</div>
-
</div>
-
Sign in to post your reply or Sign up for a free account.
Similar topics
by: nam |
last post by:
could someone please help me with this bizarre problem -
I've created a swf file at the top of my html page. The
swf file (using Swish) is simply a menu of 5 links to 5
anchor points on the html...
|
by: sean |
last post by:
/////////////////////
var xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
xmlhttp.open("POST", "http://somesite/logon.asp", false, "domain\username",
"password");
xmlhttp.send();...
|
by: Todd Cary |
last post by:
One of my clients wants me to incoroporate a Flyout menu in the left
panel. I found the Washington U has some demos on Flyout menus, however
their demo "creeps" down the page when run in IE 6; not...
|
by: Murray Patrick via DotNetMonster.com |
last post by:
I am only just begun using .net etc. I create a program (etc), it compiled
and ran on the local machine. The program was then uploaded on a remote
server. I have found in testing it that the...
|
by: sck10 |
last post by:
Hello,
I have a table with some controls in it, but it is not rapped in a form. I
also have a button for reseting the page. When I click the button, the page
resets, but I get the following...
|
by: lev |
last post by:
Attempting to use javascript's regular expression methods to match a
particular lab number and building which would then be copied to a pair
of textfields, I found that general matching characters...
|
by: nandakumar.raghu |
last post by:
Hi,
I have written a javascript function that acceses properties from an
activex object. -
<OBJECT id="alertObj"
classid="clsid:AEE77194-B98F-4E0E-A27F-4AD6B23F0038"></OBJECT>
function...
|
by: SysTechGuy |
last post by:
I am a Systems Tech for a Library Consortium and one of our library clients wants to know if "there are any free internet sites for javascript flyout menus."
If I understand his question, I think...
|
by: viki1967 |
last post by:
Hi all.
I have problem with this string javascript:
onclick="if(confirm('Confirm?')) location.href('form.asp?A=terry.d'arby'); return false;
The error javascript is:
Error: Expected ')'
...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
| |