Using a jQuery hover effect to slide a span element

I have designed custom share buttons to enhance the appearance of the traditional like, tweet, pin, etc. However, I am facing an issue with hover functionality in a jsfiddle demo. The buttons almost function as intended, but I need the span element to remain out of the way during hover so that users can click on the button underneath without any hindrance. I have been unable to solve this problem on my own. Give the fiddle a try to better understand the issue.

HTML:

<div class="sharebuttons">
    <ul>
        <li id="tweet"><span></span><a href="">tweet</a></li>
        <li id="like"><span></span><a href="">like</a></li>
        <li id="pin"><span></span><a href="">pin</a></li>
        <li id="plusone"><span></span><a href="">plusone</a></li>
    </ul>
</div>

JS:

$(document).ready(function(){
    $('.sharebuttons ul li span').hover(function(){
        $(this).slideUp();
    }, function(){
        $(this).slideDown();
    });
});

For a working demonstration, visit the fiddle link below

http://jsfiddle.net/bgxZB/

Answer №1

To achieve the desired effect, make sure to target the hover event on the li element rather than the span:

$(document).ready(function(){

    $('.social-media-buttons ul li').hover(function(){
        $(this).find('span').slideUp();
    }, function(){
        $(this).find('span').slideDown();
    });

});

Check out the demo here

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

Creating a grid in JavaScript using a formula

I'm looking to create a grid of objects using JavaScript. Unfortunately, I can't remember the formula and I haven't been able to find it online: var width = 113; var height = 113; var col = 10; ...

Display only one difference when the document is loaded, then reveal the other divisions after the "change"

For my business options form, I am working on a feature where the user selects an Entity Type (such as Corporation, LLC, LLP) from a dropdown menu and then a new form appears. Here is what I have attempted: HTML FILE <head> <link rel="styles ...

Ways to activate a disabled button based on a condition in vue.js?

I am currently facing an issue with the 'submit' button that I have disabled under van-submit-bar. My requirement is to enable it once the user chooses a table number from the dropdown options. The default selection in the drop-down menu is &a ...

Can Express.Multer.File be inserted into a FormData object easily?

Can anyone assist me in figuring out how to add a file of type Express.Multer.File into a FormData object? Situation: I have received a file with the type Express.Multer.File (I am using nestjs and followed this part of the documentation: https://docs.nes ...

Is the main content positioned below the sidebar on smaller screens?

In order to achieve a 250px col-2 sidebar with a col-10 main body that collapses into a top navbar and main content beneath it, my goal is set. However, I am facing an issue where the main content body goes underneath the sidebar when the screen size cha ...

Transmitting an unformatted array using mongoose

I am currently developing an intranet application using node.js, body-parser, and mongoose to store form data in my database. Everything is working smoothly as the specific form posts on the website as intended. Now, I am looking to enhance this feature by ...

What is the best method to override the CSS transition effect with JavaScript?

I am trying to implement a CSS transition where I need to reset the width of my box in advance every time my function is called. Simply setting the width of the box to zero makes the element shrink with animation, but I want to reset it without any animati ...

Sending multiple unique forms with the same structure using JavaScript and Ajax on a single PHP page

In my PHP page, there are 12 individual forms with unique form IDs, checkboxes, and dropdowns. Take a look at this image: https://i.stack.imgur.com/pODzk.png Each form has an Update Zone that fetches Name, Enable status, Time, Dim information, and sends ...

Adjust the size of the event bar on the FullCalendar resourceTimeline view

In my implementation of FullCalendar v6, I am displaying 6 months worth of data in the calendar, with each slot representing a one-month period. The issue I am facing is that when creating an event spanning 10 days, it currently takes up the entire width o ...

Hover not registering on Iframe element in all versions of Internet Explorer

Currently facing an issue with iframe:hover. The iframe on my website is hidden, and when I hover over a link or the iframe itself, it should become visible. This functionality works perfectly in most browsers, except for Internet Explorer (all versions). ...

Experimenting with Jquery Ajax JSON on a local environment

Seeking help in testing if the form data is being saved as JSON format after submitting it via API. Any assistance would be greatly appreciated. <form id="reg-form" method="post" action=""> <div class="form-group"> <label for="yourname" ...

SASS: a common thread connecting multiple applications

The scenario involves a web platform that aggregates various React apps, each with its own .scss files. The goal is to extract the common .scss into a library for convenience. Any suggestions on how best to accomplish this? It's important to note that ...

Encountering a problem when attempting to utilize AngularFire's Cloud Messaging Angular module due to missing configuration values for the app

Working with Firebase Cloud Messaging in my Angular application using AngularFire2 has presented a challenge. I am facing an error when attempting to retrieve the user's current token. I have already set up the "firebase-messaging-sw.js" and "manifes ...

.then function not functioning properly in Axios DELETE request in a React project

I am currently facing an issue with calling a function to update the array of notes after deleting a note from the database. The function causing the error is called deleteNote, and the function I intend to call within the .then promise is getNotes. Here i ...

Tooltip for dynamically fetched data cell within a Bootstrap table

Can anyone provide guidance on how to implement a tooltip for a data cell that receives data from an ajax request? I have not been able to locate any relevant information in the official documentation: I understand how to add tooltips when data is genera ...

Change the body class on touch start instead of using .scroll()

My JavaScript code is designed to add a class to the <body> element while the user scrolls: var $body = $('body'); $(window).scroll(function() { $body.addClass('scrolling'); var scroll = $(window).scrollTop(); if (scr ...

Refining checkboxes with specific criteria

I am struggling with the following code: <form method="post"> <% for(let i = 0; i < websites.length; i++){ let website = websites[i]; %> <fieldset id="site<%= i %>" style="padding-bottom: 0; padding-top: 10p ...

Unable to see the array values in jquery autocomplete

Hey there, I'm currently using jQuery autocomplete with CodeIgniter. My result array is fetched from the database and I am sending it back as JSON-encoded data. However, I am facing an issue where the values in the search results are not being display ...

What is the best way to wait for a DataTable() to finish loading data via ajax and

In the JavaScript code I've written using jQuery, I have a DataTable that needs to be loaded with data before any further actions can be taken. Here is my current code: function f () { /* ... */ $('#my_datatable').DataTable().ajax. ...

The result of Ajax FormData is empty

Recently, I designed a form through which I am transmitting data in JSON format. When I submit the formData and make changes to the controller to handle [FromBody] Image requests, while setting the contentType and processData options to false, the formData ...