Reset the queue for the slideDown animation using jQuery

I am experiencing an issue with my code where multiple animation effects are running simultaneously. Specifically, when I hover over navbarli1 and then move to another li element with the same navbarli1 class, the slide-down effect is not working as expected.

Here is the HTML structure:

<li class="navbarli1">
   <div class="liHover">
      <a href="" title="">آموزش</a>
      <div class="SubMenu">
         <ul class="ulsubmenu">
            <li>کلاس های حضوری</li>
            <li>کلاس های غیر حضوری</li>
         </ul>
      </div>
   </div>
</li>
<li class="navbarli1">
   <div class="liHover">
      <a href="" title="">فروش تجهیزات</a>
      <div class="SubMenu">
         <ul class="ulsubmenu">
            <li>سخت افزاری</li>
            <li>نرم افزاری</li>
         </ul>
      </div>
   </div>
</li>

This is the jQuery code for the animation:

$(".navbarli1").mouseover(function () {
    $(".ulsubmenu", this).stop().slideDown("medium");
});
$(".navbarli1").mouseout(function () {
    $(".ulsubmenu", this).stop().slideUp("medium");
});

Answer №1

Does this look similar to this?

This is the current code I am working with:

$(".menu li").hover(function () {
    $(this).find(".submenu").eq(0).stop().slideToggle();
});
$(".menu li").mouseleave(function () {
    $(this).find(".submenu").eq(0).stop().slideToggle();
});

This code specifically targets elements with the class .submenu. The method eq[0] selects the first occurrence of this class. Feel free to replace slideToggle() with slideUp() and slideDown() if you prefer.

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

jQuery element with listener not triggering as expected

I'm facing some confusion while working on this issue. I am attempting to create a dynamic form where users can add descriptions, checkboxes, and number inputs as they please. Currently, I have developed a simple dynamic form using jQuery, which allow ...

Leverage the geocode callback function results from Google Maps in NodeJS to render a map on the AngularJS 2 component template

Hey there, I'm currently utilizing the Google Maps Node.js client web API and want to showcase a map on my HTML views using AngularJS 2. I have a server export that sends an object to my AngularJS2 client service const googleMapsClient = require(&ap ...

dynamic color-changing feature on the menu

I have a navigation bar on my website with a set of sub-menus that appear when hovered over. I want to make the navigation bar change color dynamically each time it is hovered over. Additionally, I would like to add a range of colors to choose from. For ...

Issue with confirming deletion of tabulated records

HTML Code: <td>random_data_1</td><td><button id="random_data_1"></button></td> <td>random_data_2</td><td><button id="random_data_2"></button></td> <td>random_data_3</td ...

What causes my divs to change position when using text <h1>?

When I have multiple divs grouped together inside another div, the placement of my h1 tag shifts downwards. How can I prevent this from happening and ensure that the text is added without any unwanted shifting? This issue only occurs when there are two o ...

Having issues with Tailwind classes not being applied properly on dynamically generated pages in Gatsby-node

Currently, I am working on building dynamic pages using gatsby-node. The templates for these pages are stored in the templates/ directory. However, I have run into an issue where I cannot utilize tailwind classes within these templates unless they are al ...

Different option for positioning elements in CSS besides using the float

I am currently working on developing a new application that involves serializing the topbar and sidebar and surrounding them with a form tag, while displaying the sidebar and results side by side. My initial attempt involved using flex layout, but I have ...

bootstrap thumbnail displayed without a border

I have decided to incorporate Bootstrap into my latest project: <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS ...

Modifying CSS files in real-time

I've been attempting to dynamically change the CSS file, but I've run into an issue: Whenever I try to alter the style, it seems to work correctly while in "debug mode", showing that the changes are applied. However, once the JavaScript function ...

Confirming user credentials for every page

I am currently working with an HTML page that includes front end PHP for server side scripting. One issue I have encountered is the configuration page, which can be accessed by disabling JavaScript in Mozilla settings. My current validation method relies ...

JSF and jQuery: Efficiently Binding Events by ID

Encountering a problem with JQuery and JSF/Richfaces. The issue lies within an inputText component nested inside a form component. <h:form id="myForm"> <h:inputText id="myInputField" value="#{myBean.sampleName}" /> Here is the jQuery code ...

Managing the display of my website's screenshots within the list of recently visited sites on the browser's new tab page

Internet browsers like Firefox and Chrome have the ability to take screenshots of visited websites and display them as "recently used websites" on a new tab. However, if your website contains confidential information, you may be wondering how to prevent b ...

More content will not be displayed beneath folded DIVs arranged to stack on mobile devices

On my website, I have two separate sections dedicated to use cases and benefits. Here is the code: .onboardmessaging { min-width: 100%; } .onboardmessagingwrap { min-width: 100%; } .usecase { padding-left: 8vw; max-widt ...

Symfony: The Database Query Button with a Pop-up Feature

I am looking to create a button that will automatically search my database for all users with a "secouriste" attribute set and display their first name, last name, and phone number in a popup. After conducting research, here is what I have gathered: In m ...

What is the best way to retrieve response data from php using ajax in a single file?

Trying to retrieve PHP response data using AJAX has been a challenge for me. My goal is to search for a specific string in testing.txt based on user input. If the string is found, PHP should output "1", but no matter what I attempt, AJAX consistently retur ...

Ensure that a synchronous action is performed prior to each Backbone HTTP request

For each authenticated request (GET, POST, etc) in my Backbone/Marionette application, it is necessary to include an accessToken. The accessToken and expireDate are stored in the localStorage. To verify if the accessToken has expired, I utilize the metho ...

Error encountered in Django when attempting to pass an SQL query due to an UnboundLocalError

When I encountered an issue: Environment: Request Method: POST Request URL: http://127.0.0.1:8000/mainpage.html Django Version: 3.2.12 Python Version: 3.7.4 Installed Applications: ['django.contrib.admin', 'django.contrib.auth' ...

No data returned from Ajax request

I am using jQuery serialize and Ajax to capture form values and process them with JSON as the data type, but I am not getting any values returned. I have tried different approaches to troubleshoot this issue, but so far I haven't been successful. Ther ...

Utilizing checkboxes for toggling the visibility of buttons in Angular

I want to dynamically show or hide buttons based on a checkbox. Here is the HTML code I am using: <input class="form-check-input" [(ngModel)]="switchCase" type="checkbox" id="flexSwitchCheckChecked" (change)=" ...

Utilizing Knockout JS to populate a dropdown list with options fetched from a JSON object retrieved through an AJAX request

Seeking assistance with using knockout js for data binding in my single page web application. I am looking to populate a dropdown list by utilizing a json object returned as response from an ajax call to the server. Below is my model and ajax call code. An ...