Is it possible to display dual tooltips on a single div using Materializecss?

Hey there! I'm working on a form using Materialize and the collapsible component to display it. I want to include two tooltips for each category in the accordion: one to show the category name and another to display "Active" when an option is selected.

Here's my current code snippet:

function obtain() {
  var selectCloud_and_or = $("#And_OrCloud").find("option:selected").text();
  $("#cloud_AndOr").text(selectCloud_and_or);
}
$('select').change(obtain);
obtain();
.collapsible {
  margin-left: 80px;
}
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/materialize/0.98.0/css/materialize.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/materialize/0.98.0/js/materialize.min.js"></script>
<script type="text/javascript">
  $(document).ready(function() {
    $('.collapsible').collapsible();
  });
</script>

<!-- select option -->

<script type="text/javascript">
  $(document).ready(function() {
    $('select').material_select();
  });
  $('select').material_select('destroy');
</script>

<!-- Tooltip -->
<script type="text/javascript">
  $(document).ready(function() {
    $('.tooltipped').tooltip({
      delay: 50
    });
  });
</script>

<ul class="collapsible" data-collapsible="accordion">
  <li>
    <a class=" tooltipped" data-position="left" data-delay="50" data-tooltip="First">
      <div class="collapsible-header"><i class="wi wi-cloudy"></i></i><span id="cloud_AndOr"></span><span class="clouds"></span></a>
    </div>
    <div class="collapsible-body">

      <div class="row">
        <div class="col s12 offset-s4">
          <select class="and-or" id="And_OrCloud" name="a_o[]">
                <option value="4" selected="selected">And</option>
                <option value="5">Or</option>
              </select>
        </div>
      </div>
    </div>
  </li>

I'm looking to have two tooltip elements: one that shows up when the user hovers over the accordion anywhere, and another that appears when hovering over the "and/or" option within the accordion header. Currently, I only have one tooltip implemented. How can I add the second one?

Answer №1

To create a tooltip for your collapsible-header, simply add the class "tooltipped" and the attribute data-tooltip="Message".

What does this do?

This setup allows you to turn your collapsible-header into a container that can display a tooltip message specified in the data-tooltip attribute.

function obtain() {
  var selectCloud_and_or = $("#And_OrCloud").find("option:selected").text();
  $("#cloud_AndOr").text(selectCloud_and_or);
}
$('select').change(obtain);
obtain();
.collapsible {
  margin-left: 80px;
}
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/materialize/0.98.0/css/materialize.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/materialize/0.98.0/js/materialize.min.js"></script>
<script type="text/javascript">
  $(document).ready(function() {
    $('.collapsible').collapsible();
  });
</script>

<!-- select option -->

<script type="text/javascript">
  $(document).ready(function() {
    $('select').material_select();
  });
  $('select').material_select('destroy');
</script>

<!-- Tooltip -->
<script type="text/javascript">
  $(document).ready(function() {
    $('.tooltipped').tooltip({
      delay: 50
    });
  });
</script>

<ul class="collapsible" data-collapsible="accordion" >
  <li>
    <a class=" tooltipped" data-position="left" data-delay="50" data-tooltip="First">
      <div class="collapsible-header tooltipped" data-tooltip="Another tooltip"><i class="wi wi-cloudy"></i></i><span id="cloud_AndOr"></span><span class="clouds"></span></a>
    </div>
    <div class="collapsible-body">

      <div class="row">
        <div class="col s12 offset-s4">
          <select class="and-or" id="And_OrCloud" name="a_o[]">
                <option value="4" selected="selected">And</option>
                <option value="5">Or</option>
              </select>
        </div>
      </div>
    </div>
  </li>

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

Could Google Adsense be causing issues with my website's navigation bar?

There seems to be an irritating bug that I've come across. While navigating my website, [the menu (located in the top right corner) functions correctly]. However, when you land on a page with a Google AdSense ad, the menu suddenly appears distorted ...

I am unable to achieve negative X degree rotation of the image while using mousemove to rotate it

I need assistance with moving a picture in 3D. I want the offsetX of the mouse to be positive when it's past half of the picture, and negative otherwise. How can I achieve this effect for rotation degrees? This is what I have tried: $('#img ...

Navigating with ExpressJS

I am looking to enhance the flexibility of routing for handling slashes, such as app.get('/home/pages') The router should be able to manage ////home///pages /home/pages//// etc... requests. I have a potential solution in mind, but it requ ...

To enhance the MUI v5 table row, simply apply a border when the mouse hovers

After working on creating a table with Material UI v5, I encountered an issue where I wanted to add a blue border to the table row when the mouse pointer hovered over it. I attempted several methods and did thorough research, but unfortunately, I was unab ...

Difficulty arises with a simple click, resulting in two separate form submissions

I am aiming for the user to complete one form and utilize JavaScript to post the form into two different places. To achieve this, I have created a JSFiddle found here. On my website, there is a single form with an input[type='submit'] button. U ...

What is the proper way to retrieve a function from an angular module?

Here is a snippet of AngularJS code for a wallet module: angular.module("app.wallet", ["app.wallet.directive", "app.wallet.service"]), angular.module("app.wallet.service", []).factory("$wallet", ["$rootScope", "$$http", "$e", "$toast", "errorMap", "$popu ...

toggle classes using jQuery when a link is clicked

I'm currently working on a jQuery function that will apply a class to a selected link (which opens a page in an iframe) and then remove that class when another link is chosen. Previously, I received assistance from another member for a similar task in ...

Explain the concept of paragraph spacing in Word, including how it is

When working with my ms word 2010 document, I often use the includetext-function to incorporate HTML content: { INCLUDETEXT "test.html" } Here is an example of the HTML code that I am trying to include: <html> <head> <meta http-equiv="Co ...

Error message: "req.session.passport is undefined in subsequent requests with Express and Passport."

I've recently embarked on a small project using React with Redux on the client side and Node, Express, and Passport.js on the backend. I've been struggling with a specific issue for some time now and could use some help. After authentication, wh ...

Enhancing a collection of HTML buttons

I am trying to modify an array of HTML buttons using a JavaScript function called getButtons: function getButtons() { // This function generates buttons displayed in the selection phase. var trialButtons = [ '<button class="jspsych-btn&quo ...

Django Ajax Form submission automatically refreshes the page upon successful completion

I recently encountered some issues with django and ajax in my previous post (Django Ajax Image submit). After some modifications as mentioned in the EDIT section, I found myself in the following situation: Below is my jquery/ajax call: <script> ...

From HTML to Mat Table: Transforming tables for Angular

I am currently facing a challenge with my HTML table, as it is being populated row by row from local storage using a for loop. I am seeking assistance in converting this into an Angular Material table. Despite trying various suggestions and codes recommend ...

Dealing with multiple JSON objects and organizing them into an array

After making an ajax call, I receive a response consisting of multiple JSON objects. // Sample response from ajax call: {"name":"suresh","class":"10th"},{"name":"suresh","class":"10th"} I am looking for assistance in splitting these objects and storing t ...

Is it possible to retrieve the output following deferred execution in a jQuery plugin without utilizing a callback function

I have created a plugin that returns the direction (such as top, left, etc.) of the side through which you enter an element. The issue I am facing is that one of the functions inside the plugin is executed after a timeout, causing the plugin to return unde ...

Sync your data effortlessly with jQuery Datalink, the ultimate solution for

While experimenting with the jQuery Data linking proposal by Microsoft, I came across an unexpected discovery. There seems to be an additional property present in my objects, and I am curious as to why it is there. Initially, I thought it was a mistake on ...

Restrict the number of clicks allowed on a button

I am working on a project for my college where I need to restrict the number of times a button can be clicked to only 3 times. I have searched everywhere for code to achieve this and finally found some yesterday. The code is functioning partially as it giv ...

Could you explain the contrast among "yarn serve," "yarn start," and "yarn build"?

Although both "yarn serve" and "yarn start" can launch my Vue project, I'm unsure of the differences between them. I've heard that "yarn build" is for packaging, but why don't I use it at work? Usually, I just upload my code to git and let ...

ExpressJS, defining routes, locating controllers, and documenting APIs

Utilizing expressJS 4.X and nodeJS 6.x In the past, I was defining my routes in this manner : /** * @api {get} /users/:userId Get a user * @apiName GetUser * @apiGroup User * * @apiParam {Integer} userId Users unique ID. * * @apiSuccess (Success 2 ...

I could really use some assistance with the concept of "AJAX" - can anyone help

After spending several months working with AJAX, I have come to understand the typical request lifecycle: Sending parameters to a background page (PHP/ASP/HTML/TXT/XML ... what other options are available?) Performing server-side processing Receiv ...

Learn the process of extracting an array of objects by utilizing an interface

Working with an array of objects containing a large amount of data can be challenging. Here's an example dataset with multiple key-value pairs: [{ "id": 1, "name":"name1", age: 11, "skl": {"name": & ...