Looking to automatically dismiss a tooltip on mobile devices a few seconds after it's tapped

Here's an anchor tag with a tooltip:

<a data-toggle="tooltip" data-original-title="Apologies, pronunciation audio is currently unavailable.">
    <span class="glyphicon glyphicon-volume-off pronounce">
    </span>
</a>

When viewing on desktop screens, the tooltip will only appear when the anchor is hovered over or clicked and will disappear when the mouse pointer moves away. However, when viewing on mobile screens, the tooltip will stay visible even after tapping the anchor. Is there a way to make the tooltip fade out after a certain amount of time specifically on mobile devices?

UPDATE: Just for reference, my tooltip JavaScript code looks like this:

$(document).ready(function() {
    $("body").tooltip({ selector: '[data-toggle=tooltip]' });
});

Answer №1

If you're looking for a solution, try this out:

$('body').click(function(event){
    if (event.target.id != 'tooltip'){
        setTimeout(function(){
            $('#tooltip').tooltip('hide');
        }, 2000);
    }
});

Check out the code on JSFIDDLE : https://jsfiddle.net/c7ym1ox9/5/

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

Issues arising from the event target

What is the reason behind this code functioning successfully only when the alert function is called? The color changes after closing the alert box, but if the line with the alert command is commented out, nothing happens. function setLinkColor(el) ...

Is it possible to manipulate the content inside a div tag using JavaScript in HTML?

What is the most efficient way to dynamically adjust a data offset value within an HTML tag using JavaScript? For example: <div class="box" data-offset="2s"></div> I am looking to update the value within the data-offset attribute based on s ...

Toggle the functionality of the login button in foundation

I am currently utilizing the front-end framework Foundation. My question is, how can I modify this menu so that the Log in button is only enabled when both the Login and Password input fields are filled with text? <form data-abide="ajax"> <div ...

What is the process for converting HTML assets into a SCORM package?

**css styles fonts images media menu1_images menu2_images menu3_images menu4_images** index.html index_custom.js index_actions.js menu1.html menu1_custom.js menu1_actions.js menu2.html menu2_custom.js menu2_actions.js menu3.html menu3_custom.js menu3_actio ...

I am in need of setting up two rows side by side using the display

I'm trying to have two rows side by side using display grid, but I'm facing some issues. When I use the following CSS... .grid-container { display: grid; grid-template-rows: auto auto; grid-template-columns: auto; grid-column-gap: 100px;} It cre ...

sent a data entry through ajax and performed validation using jquery

Is there a solution to validating the existence of an email value using ajax after validation work is completed? Despite attempting to check for the email value and display an alert if it exists, the form continues to submit regardless. See below for the ...

The datetimepicker is not functioning properly

I'm experiencing an issue with the datetimepicker where it doesn't display a calendar when I click the icon. Interestingly, the Chrome browser isn't showing any errors in the development console. <script src="Scripts/jquery-2.1.1.min.js ...

Is this code in line with commonly accepted norms and standards in Javascript and HTML?

Check out this Javascript Quiz script I created: /* Jane Doe. 2022. */ var Questions = [ { Question: "What is 5+2?", Values: ["7", "9", "10", "6"], Answer: 1 }, { Question: "What is the square root of 16?", Values: ["7", "5", "4", "1"], Answer: ...

Eliminating the border of a table that is contained within a cell

I am facing an issue with a nested table where I need to remove the borders from specific cells (around A and B). Here is the code snippet: <style> .withBorders tr td{ border: 1px solid black !important ; } .withBorders table. ...

The container or row I placed in the middle of the page content is not anchored to the bottom like it should be for footer widgets

I'm struggling with the code I've extracted. How can I move the footer widget to the bottom of the page? On some pages, the footer displays at the bottom because there isn't much content, but on one specific page, it appears in the middle of ...

Using JavaScript and Tampermonkey to convert strings from an HTML element into an array

I am trying to change the names of months into numbers and place them in a table cell on a website. I thought using an array would make it easier to reference the month names by their corresponding array numbers, allowing me to add table tags before and af ...

Refreshing the page after executing a MySQL UPDATE statement

There seems to be a problem with the page refreshing faster than the query execution. I have an UPDATE query to update my database with values in my fields, triggered by pushing a button. However, upon clicking the button (which refreshes the website), th ...

Issues with CSS not loading properly on EJS files within subdirectories

This is the structure of my folders (with views located in the root directory): views/contractor/auth/login.ejs When I access that file, the CSS styles are not being applied. The connection to the CSS file, which is located in the public directory in th ...

Getting the CSS for an element's "Active" state using jQuery

Is there a way to retrieve the CSS for the :active state using jQuery? I am looking to create dynamic code so that I don't need to manually adjust the jQuery every time I want to style an element. Edit To clarify, I am trying to avoid using .addClas ...

Unable to retrieve value from a hidden input field using JavaScript

My goal is to retrieve a value from a hidden inputbox using JavaScript. However, I am encountering issues where sometimes I receive an "undefined" error and other times there is no output at all. When I utilize alert(document.getElementById('hhh& ...

Updates made to CSS are not appearing on the Joomla site

My website is based on Joomla and has been functioning well since it was created. However, recently I have noticed that any CSS changes made in the files are not showing up on the site. I have tried clearing the cache and viewing it from different ISPs, ...

What is the best way to differentiate between two CSS elements with the same class name?

I ran into an issue where two elements share the same class name, specifically "img" Is it possible to apply different styles to these elements that are nested under different parent classes, despite having the same class name? I am trying to customize t ...

Enigmatic void found beneath image surfacing

Similar Question: Dealing with Additional Space at the Bottom of an Anchor Tag Take a look at this example page here.. There seems to be a mysterious gap below the picture of the family, just before the gray-bordered (5px #333) div that holds the ima ...

What Is Preventing my Bootstrap Tabs from Displaying their Content?

I've been attempting to implement the nav-tabs feature from Bootstrap (version 5.2.2) into my Angular application. However, I've encountered an issue where only the content in the first tab is visible, while the contents of the other tabs remain ...

Adaptable HTML design with alignment features

Here is the structure I am working with: <style> #main { max-width: 500px; margin: 0 auto; overflow: hidden; border: 1px solid red; } #container{ margin-right: -50px; } .block{ display: inline-block; width: 100px; height: 100px; border: 1px solid gr ...