Activate div2 visibility upon hovering over div1 using jQuery

I have a shopping basket on my website, and I want to display a list of products when a user hovers over the basket icon. However, I am facing an issue where the list disappears as soon as the mouse leaves the basket logo. Is there a way to keep the list visible until the mouse moves out of the listbox? Below is the code snippet I'm using:

<div id="basket" style="padding:10px; background-color:#00458b;color:white;position:relative;cursor:pointer; width: 130px;z-index:1000;">Basket</div>
<div id="list" style="padding:10px; background-color:#63a0df;color:white;position:relative; width: 200px; display: none;z-index:1100;" >
<ul id="products">

</ul>
<button type="button" class="unset">Destroy</button> 

</div>

$('#basket').bind({
        mouseenter: function() {

        $("#list").fadeIn("slow", function() {

        });
        },
        mouseleave: function() {
        $("#list").fadeOut('fast');
        }
    });

Answer №1

Enclose your blocks within a common div to ensure that the #list remains visible until you exit from that shared div.

Give this method a try:

<div id="basket" >
<div style="padding:10px; background-color:#00458b;color:white;position:relative;cursor:pointer; width: 130px;z-index:1000;">Basket</div>
<div id="list" style="padding:10px; background-color:#63a0df;color:white;position:relative; width: 200px; display: none;z-index:1100;" >
</div>

Check out the DEMO

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

Strange fuzzy ring on Safari IOS HTML5 videos

There is a strange circular shape that keeps appearing on certain websites (image below) when viewed on an iPhone using Safari. Upon inspecting the Safari console, it seems to be related to the autoplay feature of a video, but unfortunately, I have been un ...

The update feature seems to be malfunctioning within the MEAN Stack environment, specifically with node.js and angular js

Looking for some assistance as a beginner in the mean stack. I'm trying to update a record using the update function, but it's not working as expected. I need to update a specific object based on its ID, however, I'm encountering issues wit ...

Track and manage date ranges inclusive of specific times

http://jsfiddle.net/7vzapm49/1/ var startdatearr = [new Date("04 Dec 2014 14:30:00").toUTCString(), new Date("07 Dec 2014 14:30:00").toUTCString()]; var enddatearr = [new Date("05 Dec 2014 14:30:00").toUTCString(), new Date("08 Dec 2014 14:30:00").toUTCSt ...

What is the best way to incorporate npm packages and ES6 features into Django?

As I work on the frontend development of my Django application, I am keen on incorporating the official material design components. Yet, I am faced with a challenge in seamlessly integrating these components. I am looking for a way to import the npm packa ...

Converting jQuery ajax success response data into a PHP variable: A step-by-step guide

When sending data to a php page for processing using jQuery and ajax, I receive a response in the form of: success: function(data){ mydata = data; } The data retrieved is a URL represented as mydata = https://myurl.com. Now, I want to assign this data to ...

Utilizing the jQuery `.map()` function to generate objects within the mapping process

Greetings, I am currently in the process of developing a geocoder and I need to transmit a JSON map to the groovy backend. I am attempting to convert this unordered list structure: : http://jsfiddle.net/PJFVN/1/ <ul id="hiddenmap"> <li class=" ...

How to attach input to function invocation in Angular 2

Can we connect the @Input() property of a child component to a parent component's function call like this: <navigation [hasNextCategory]="hasNextCategory()" [hasPreviousCategory]="hasPreviousCategory()" (nextClicked)="next ...

It appears that the validation and onChange event handler in Material-UI's TextField are not functioning as anticipated

Currently, I am working with React and Material-UI's TextField component using type='number'. The default validation provided seems quite simple, allowing any character that could potentially represent part of a number [0-9\.eE-]*. This ...

Having trouble retrieving the array index of JSON data in Vue JS?

I have a project that includes data from a JSON API and I'm trying to display the index of each data. For example, I can view the floors from array index 0 to 22, but I'm having trouble getting the array index for the flats on each floor. Each fl ...

What is the best way to integrate data-bs-toggle into my code?

I am currently exploring the use of data-bs-toggle with Bootstrap, but as a newcomer to the framework, I might be missing something essential in my setup. When attempting to implement data-bs-toggle, I notice that my autocomplete suggestions only include d ...

Utilizing Arrays for Angular Data Binding with AJAX

I am currently experimenting with loading Ajax data into an array and then binding the array using Angular. Here is my code (I have some experience with KO, so I'm keeping it simple for now): Update: I managed to get it working. I believe the issue w ...

Challenges with creating a contact form using bootstrap modal

I'm facing an issue with a bootstrap modal contact form. It works fine on all browsers except for iPad/Safari. Can anyone help me figure out what's wrong? On iPad, the modal is positioned to the right and down the page instead of in the cente ...

When iterating through a loop, the final value in an array is often overlooked

I have been attempting to iterate through an array to determine if any of the values, when compared to all other values in the array using the modulo operation, do not return a 0. Essentially, this process should only return the prime numbers in the array ...

Is there a way to dynamically update the TargetControlID of an AutoCompleteExtender using client-side JavaScript?

Typically, I am able to set the TargetControlID on the server side using code similar to this: AutoCompleteExtender ace = new AutoCompleteExtender(); ace.ID = "AutoCompleteExtender1"; ace.TargetControlID = "whatever"; While I understand how t ...

What is the best method to initiate a page refresh from a different page without redirecting?

My website consists of numerous pages like this, each with unique GET parameters such as benchmark.php?game_id=87 which fetches game information from a database and includes an Edit button. Upon clicking the Edit button, a new window is opened using JavaS ...

Error message: "jQuery Ajax CORS request returning undefined value"

I am delving into the world of cross-domain Ajax requests for the first time by interacting with an API. Utilizing jQuery, I aim to extract specific elements from the response and display them on the webpage. Here is the code snippet for the request: $.a ...

Tips to position two shortcode elements next to each other horizontally

I have some code here and I am looking to align the two elements at the bottom, "php echo do_shortcode(wcas-search-form);" and "php do_action('hamzahshop_custom_min_cart');" on the same line horizontally. I am new to this and struggling to figure ...

What is the best way to showcase the following values using Vue.js?

{"status":true,"data":[{"ref_id":"22","agent_id":"68","p_id":"84","description":"i am interested"},{"ref_id":"24","agent_id":"68","p_id":"84","description":"For more information about Bootstrap and Bootstrap Glyphicons, visit our Bootstrap Tutorial.For mor ...

Successively linking promises together within a for-each iteration

How can I ensure that a foreach loop is synchronous in AngularJS var articles = arg; articles.forEach(function(data){ var promises = [fetchImg(data), fetchUser(data)]; $q.all(promises).then(function (res) { finalData.push(res[1]); ...

Obtain consistent outcomes by entering identical data in both Ajax and PHP

My code takes a number input in a <textarea>, then uses AJAX to validate it randomly with PHP (using rand()). The validated number is returned along with the words correct or incorrect to a <div> in HTML. The issue is that if the same number i ...