Displaying Text on Mouseover with JQuery

I have created a unique set of graphs that unveil hidden text when hovered over with the mouse. To start, I carefully outlined the layout of my text:

<article class="fundamental_metrics">
    <h2>Fundamental Metrics</h2>
    <p id="number_of_transactions"></p>
    <p id="total_transaction_volume"></p>
</article>

Here is the corresponding CSS styling:

.fundamental_metrics{
    height: 100px;
    width: 100px;
    display: none;
    z-index: 1;
}

Notice how the display property is set to none. Next, I implemented some JQuery code to enhance this feature:

          $(document).ready ( function () {
                $(document).on("mouseenter", "svg", function () {
                    console.log("mouse enter");
                    $(this).css("opacity","0.5");

                    $("#number_of_transactions").empty().append("Number of Transactions: " +10000);
                    $("#total_transaction_volume").empty().append("Total transaction volume: " + 1000);
                    $(this).append($(".fundamental_metrics").css("display","block"));


                }).on('mouseleave', 'svg', function () {
                    console.log("mouse leave");
                    $(this).css("opacity", "1");
                });
          });

Despite correctly appending the article element to the parent class from the inspect menu, nothing seems to be visible on the screen.

https://i.sstatic.net/hU2rE.png

Take a closer look at the blue highlight area, where you can find the article tag with display: block. Initially, I suspected issues with the z-index, but even after adjusting it, the problem persists. Any suggestions?

EDIT: It's worth noting that the graphs are being generated using the D3.js library.

Answer №1

To make your code work, just exclude the svg from the event handler arguments.

On a side note: There seems to be inconsistency in naming between your article and JavaScript files - total_loan_originated versus total_loan_origination.

For a working test example that doesn't involve appending to svg, check out this linked fiddle.

Update: The text box is not being properly removed. You can see the fix in this updated fiddle: Updated fiddle link.

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

Angular 2 input delay feature

I'm currently working on an application where I need to send an event after input debounce. Here's what I have tried so far: @ViewChild('messageInput') messageInput: ElementRef; private inputTimeOutObservable: any; setTypi ...

Incorporating the outcome of an asynchronous function into my 'return' statement while iterating through an array

Issue I am Facing I encountered a problem while trying to execute a database function while simultaneously mapping an array. To illustrate this problem in a more concise manner, I have developed a sample code snippet. In my implementation, I am utilizing ...

Instructions for obtaining and assigning a reference to a recently cached associated object within the Apollo client InMemoryCache

My data consists of a set of interconnected items like this: book { id ... related_entity { id ... } } Once Apollo caches it, there are two separate cache objects. The related_entity field on book points to an EntityNode object. Everything ...

Issue with JQuery: Logo only becomes visible after scrolling

Recently, I added a jQuery script to modify the header as we scroll on our website. Everything is functioning smoothly except for one issue - the large logo on the left side doesn't appear when visitors first land on the page; it only shows up after t ...

What causes custom CSS properties to be overridden by Material UI CSS class properties?

I encountered an issue while attempting to utilize an npm package containing a Typography element from Material UI. The code is authored by me. Upon integrating it into a project, I noticed that the typography's CSS class properties were overpowering ...

Submitting Prestashop form using Ajax - Retrieving data with Tools::getValue()

Hello, I am trying to save a form into the PrestaShop database using AJAX, but I am facing some challenges. Let me share my attempt with you. HTML Form: <form action="" method="POST" class=""> <textarea name="question_content" row="4" class=" ...

AngularJS is unable to properly show the full calendar on the screen

Currently working with fullcalender.js in conjunction with AngularJS. Encountering an issue where the calendar is not displaying without any error indication, making it difficult to identify the missing component. This marks my initial attempt at combinin ...

How To Send Form Data Using JQuery AJAX for Seamless Page Updates and Retrieving Data Dynamically

Here is My Code HTML <form id="msg_form"> <input type="text" name="msg_text"> <button type="submit" name="send">Send</button> </form> AJAX $(function () { $('#msg_form').on('send', functi ...

"Exciting Changes in Color According to the Active State of vue-route-link

I am trying to find a way to customize the CSS based on whether a link is exact or active. Essentially, when a user clicks on a menu item, I want the underline to change depending on whether the link is an active router-link. Although I was able to accompl ...

Submitting Form Data from Multiple Dropdown Boxes using PHP $_POST

I have been using multiple dropdown boxes with data from a MySQL database, but I have encountered an issue when trying to $_POST the information. Below is the code snippet I am using: <?php try { $dbo = new PDO('mysql:host=' . $dbhost_n ...

Are there any alternatives to using the $size function in MongoDB for this specific tier in Atlas?

I am trying to create a code that will return certain data only if there are exactly 2 instances of the by field in the data array. The number of _id entries can vary. Unfortunately, using { $size: { data: 2 }, } doesn't work as I am encountering an ...

What is the proper way to connect files together?

In my experience, I have frequently encountered challenges when it comes to linking files in my website projects. Whether it's CSS styles, Javascript files, or including PHP files, the issue arises when the project directory on my PC is /www/project-n ...

Encountering issues with token header syntax while making an API call in Google Sheets using Apps Script

Uncertain about the correct syntax for the header bearer token section in this code snippet. ... // -------------------------------------------------------------------------------------------------- // // iTunes Music Discovery Application in Google Sheet ...

Loading Webfonts Asynchronously in NextJS Using Webfontloader

I am currently working on a NextJS app where I am using webfontloader to load fonts dynamically. function load() { const WebFont = require("webfontloader"); WebFont.load({ google: { families: fonts } }); } However, I ha ...

Automating the process of posting a file to a form with javascript

I have a piece of client-side JavaScript that creates a jpeg file through HTML5 canvas manipulation when the user clicks an "OK" button. My goal is to automatically insert this jpeg output into the "Upload Front Side" field in a form, simulating a user up ...

Fetching data asynchronously within HTML using AngularJS

I am conducting a quick test to troubleshoot why certain parts of my code are not functioning as anticipated. Within my setup, I have a controller called testCtrl and a service named myService. The goal is to retrieve data from Parse using the service and ...

Adjust the top spacing in relation to the paragraph tag using jQuery

I wish to create multiple div elements with nested p tags that are initially hidden. Upon hovering over each div, I want the corresponding p tag to move up by the negative value of its own height. For instance: The first p tag has a height of 60px and a m ...

Error: The function $scope.apply is invalid and cannot be executed

I am attempting to display the contacts list after retrieving it using rdflib.js. The data is being loaded and stored in the list within the scope. However, I am running into an issue where the $scope is not updating, and it appears that I may be calling ...

having difficulty in transmitting json data using ajax

Struggling to send JSON data to my PHP script via AJAX and it keeps returning NULL as a response. The jQuery script I'm using involves creating a JSON data on a click event and then attempting to send it to the PHP script. Here's a snippet of the ...

Commence the 10-second Redirect Timer

I implemented a page that automatically redirects the user after 10 seconds using the following code snippet. <META HTTP-EQUIV="refresh" CONTENT="10;URL=login.php"> Now, I have this PHP code that I want to display dynamically counting down from 10 ...