Issues with Jquery show and hide functionality within a list element

My menu items are displayed using show and hide functions, sliding up and down on hover.

The issue I am facing is that when a list item expands, the overall background of the menu also expands. However, when it contracts, the background also contracts. If you try to move below the expanded menu, the items get hidden immediately as you move out of the menu's boundary.

This behavior can be observed by hovering over the second and third list items.

If you hover over "New Jersey Stores" and then hover over "New York Stores," you will notice an abnormal collapsing behavior where the third list item is not properly shown.

Here is a fiddle: Fiddle

HTML:

<div class="mega-col col-xs-12 col-sm-12 col-md-4" data-type="menu"><div class="mega-col-inner"><ul>
...
</ul></div></div>

JS:

$(".parent.dropdown-submenu.mega-group").hover(
  function() {
     $(this).children('.dropdown-mega.level2').show("500");
  },
  function(){
     $(this).children('.dropdown-mega.level2').hide("500");
  });

CSS:

li.parent.dropdown-submenu.mega-group .dropdown-mega.level2 {
    display: none;
}

li {
    padding:10px;
    position: relative;
    margin:auto;
}

Answer №1

My understanding of the issue is that you have the option to utilize the jQuery selector :not(:animated).

Here's an example on jsfiddle.

$(".main-menu.submenu.mega-item:not(:animated)")

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

What is the best way to ensure a flex element occupies a greater space within another flex element using TailwindCSS?

After spending hours trying different solutions and even resorting to brute force, I am still struggling to make this work. Objective: To increase the width of the cards when the screen size is larger Below is my main component: function App() { const ...

What is the best way to save the text entered into an HTML input field into a variable in node.js?

Here is a sample of my node.js code: const connect = require('connect'); const serveStatic = require('serve-static'); connect().use(serveStatic("WebDir")).listen(80, function(){ console.log('Server running on port 80...&ap ...

Refresh a JavaScript or division without having to reload the entire page

Is there a way to refresh a JavaScript in a specific div when a button is clicked without refreshing the entire page? It would be ideal if only the div containing the JavaScript could be reloaded. I've experimented with various solutions such as: as ...

Hierarchy-based state forwarding within React components

As I embark on the journey of learning Typescript+React in a professional environment, transitioning from working with technologies like CoffeeScript, Backbone, and Marionettejs, a question arises regarding the best approach to managing hierarchical views ...

Is it possible to execute JavaScript within an Android application?

Is there a way to utilize the javascript provided by a website on an Android device to extract and analyze the emitted information? Here is the javascript code: <script type="text/javascript" src="http://pulllist.comixology.com/js/pulllist/5b467b28e73 ...

Selectors within 'not' in document.querySelectorAll are failing to function as expected

I've been attempting to find a way to replace the jQuery .not() function with native JavaScript, but so far my attempts using document.querySelectorAll have not been successful. Here is what I am trying to achieve - converting this jQuery selector in ...

Provide the succeeding line from a CSV document whenever a PHP script is executed

I have implemented highcharts to generate a real-time chart with data that updates dynamically. The chart makes an AJAX call to a PHP file which is responsible for parsing a CSV and returning the output as JSON. Below is my Highcharts/jQuery code: functi ...

Creating a Future Prediction Graph with ECharts

I am looking to create a forecast chart that includes both Actual values (presented as a line chart) and projected values (displayed as a dotted chart). An example of what I have in mind can be seen here, created using Excel: https://i.sstatic.net/q18An.pn ...

Error: Unable to access properties of an undefined value while attempting to retrieve 'getProfile'

I am attempting to pull information from a local JSON file and display it in a table using Angular 12. However, for the initial step, I just want to log the data from the file to the console. Unfortunately, I encountered an error as described in the title. ...

Struggling to make Bootstrap-5 scripts and Rails6 cooperate, even after extensive research and troubleshooting

Hey there, I'm a complete beginner when it comes to JS, Bootstrap, and webpack, although I am familiar with HTML, (S)CSS, PHP, and currently diving into RoR. My current challenge is connecting Bootstrap-5 to Rails-6. Despite reading numerous blog pos ...

What is the best way to display numerous images on a cube face while also organizing them like a gallery wall?

I'm working on creating a unique gallery wall using three.js. Currently, I have successfully rendered an image on each side like this: My goal is to place multiple images on each wall instead of just one large image. Something similar to this concept ...

Counting the number of key-value pairs for a specific key in a JSON data can be achieved by implementing

Is there a way to determine if __metadata and ItemToEkbeNav are the root elements for their children who have key-value pairs? I've attempted various methods such as Object.keys().length and Array.isArray(), but haven't been able to retrieve the ...

Using outdated props for dynamically rendered list in React/Redux

When rendering content by mapping over an array to display items individually, everything works fine until an onClick event is implemented. The onClick event uses the current index from the store to push content into an array, but for some reason it return ...

What are some ways to prevent Visual Studio from adding an extra space in JavaScript code during the build or rebuild process?

In my Visual Studio 2019 Enterprise setup, I have noticed that when I build or rebuild my ASP.net 4 MVC solution, my JavaScript files are regenerated by TypeScript. The issue is that the new JavaScript files always end up with a single trailing space after ...

Is there a way to execute a JavaScript function within a loop?

I need to repeatedly call a JavaScript function multiple times. I have attempted to do so in the following way: In Script function changeIt(strgr , idx) { //SomeCode return; } In C# protected void btn_Click(object sender, EventArg ...

Error: The property 'create' of undefined cannot be read (Material UI/enzyme)

When I mount a component, I encounter an error that does not occur when using shallow rendering. The specific error is: TypeError: Cannot read property 'create' of undefined at stylesOrCreator (node_modules/@material-ui/core/CircularProgress/C ...

Align Button to the Right Within a Div Container

Could someone help me figure out how to align a label to the left and a button to the right within a div tag? Currently, my label aligns perfectly but my button is not aligning correctly and may even be outside of the div tag. Any assistance is appreciated ...

What's the deal with Angular's factory pattern?

Is it possible to implement a true Factory pattern in JavaScript and Angular where there is no need to constantly provide the "typeName" parameter? The transition from C# to Java reference types with Angular has been quite challenging for me, and I would ...

Learn how to connect a button to a webpage using jquery while also executing another function when clicked

I would like the showAll button click to redirect to another page where the showAll function is executed and the results are displayed on the new page. Additionally, I am looking for a way to modify the console.log statement to output the result on the new ...

Differentiating between inline and block elements in HTML5

Can you explain the various categories of inline and block elements in html5? I'm having trouble distinguishing between the different types of inline and block elements in html5. ...