The Javascript code for creating a timeline animation is malfunctioning

I am trying to implement a timeline where hovering over a specific point triggers a display showing more information about that particular historical event. Despite seeming like a simple task, I am struggling to get it to function properly. As a newcomer to javascript, I'm having difficulty identifying what I might be doing wrong. Any guidance or assistance would be greatly appreciated.

<div class="line"></div>
<div class="circle"> </div>
<div class="popup display"></div>

html { 
width: 100%;
height: 400px;
}

.line {
  width: 90%;
  height: 5px;
  background-color: black;
  position: absolute;
  top: 12%;
  left: 5%;
}

.circle {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background-color: blue;
  position: absolute;
  left: 50%;
  top: 10%;
}

.popup {
  position: absolute; 
  width: 70%;
  height: 400px;
  background-color: black;
  top: 70%;
  left: 50%;
  transform: translate(-50%,-50%);
}

.display {
  opacity: 0;
}


document.querySelector(".circle").addEventListener("mouseover", function(){
  document.querySelector(".popup").classList.remove("display");
});

Answer №1

Check out this demo on: http://jsfiddle.net/9jtemxns/

I included the mouseout event listener to make it disappear when the mouse moves away from the element.

document.querySelector(".circle").addEventListener("mouseout", function(){
  document.querySelector(".popup").classList.add("display");
});

It appears that using the following CSS for .display would have a similar effect instead of adjusting the opacity:

.display {
  display: none;
}

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

Modifying the HTML <select> element with JavaScript

[resolved] I'm encountering an issue with the code below that is supposed to dynamically change the options in a second drop-down menu based on the selection made in the first menu. I've tried to troubleshoot the problem but haven't been suc ...

Getting the device id in a web application built with React JS

Currently, I am working on creating a reactjs app and I have a requirement to restrict multiple device logins for one account. To achieve this, I need a unique and persistent ID assigned to each device. In addition, I want the user to remain logged in on ...

ASP view displaying overlapping controls

I currently have a form written in ASP that incorporates JQuery for handling two elements: an image upload and a datepicker. The code snippet responsible for the image upload functionality is $(function() { $("#wcpImage").makeAsyncUploader({ uplo ...

Troubleshooting steps for resolving Heroku's "State changed from up to crashed" error caused by Mongoose connection issue

I am encountering an issue while deploying my Node.js/MongoDB app to Heroku. It crashes with the following error: MongooseServerSelectionError: connection <monitor> to 104.155.184.217:27017 closed Below are excerpts from my log: 2022-07-10T23:36:17. ...

Differences in appearance between Bootstrap 3.7 and the most recent Bootstrap (4) version causing styling concerns

I recently downloaded some code from Coursera for a Responsive Web Design course to experiment with toggling navbars. The code, which appears to be based on Bootstrap version 3.7 (included in the class materials), works perfectly fine. However, after down ...

What is the best way to combine HTML and JavaScript code within a single JavaScript file?

Is there a way to include a responsive iframe without any scroll in multiple websites by using just one line of code? I found this snippet that seems promising: <script src="testfile.js"></script> The testfile.js contains the necessary HTML a ...

Failure to Trigger Error Callback in Ajax Requests

I am encountering an issue with the error callback not being called when I pass the error function as an object parameter in a function. Strangely, when I define it directly within the ajax code, it works without any problems. var options = new Object(); ...

How do I ensure all columns have equal heights?

I have tried using flexbox, but the column heights are still not the same. I have looked at various methods on websites like W3Schools and Medium, but none of them seem to work. Initially, using the flex method worked, but it seems to be disappearing when ...

Adjust the floating menu to match the height of the content div

I'm facing an issue with the layout of my website - I have a main content div and a sidebar. The height of the content div adjusts based on the content being loaded, but I want the sidebar to always extend all the way down matching the maximum size of ...

Using Three.js to apply a sprite as a texture to a spherical object

function generateLabel(icon, labelText, labelText2, labelText3, bgColor, fontColor, transparency, xCoordinate, yCoordinate, zCoordinate){ $('#imglabelcontainer').append('<div class="imglabel" id="imglabel'+labelText+'" style ...

What is the best way to choose the checked items and calculate the total price by adding up all the prices of the selected items?

Seeking help with utilizing JavaScript to identify and collect all checked items from an HTML file. I'm looking to determine which items have been selected from a menu, each of which has an associated price. How can I access the prices of the chec ...

Fetching information from server in Python using AJAX results in 'str' object not callable error

I've searched through numerous examples on Google to resolve the issue, but I'm still unable to get it working correctly. My objective is to fetch data from the server after clicking a button. The current error that I am encountering is: Tra ...

Struggling with making JSON.parse() function properly in a Discord Bot

I have a separate JSON file connected like this const Players = require('./Database/Players.json'); and a parser that handles the code client.on('message', message => { if (message.content.toLowerCase() ==='smack activate ...

Distinguish between datalist selection and text input in BootstrapVue Autocomplete

When looking at the code snippet provided below, I'm trying to figure out the appropriate event/method to determine whether the value entered in the input field was manually typed or selected from the <datalist>. SAMPLE CODE: <div> &l ...

Tips for syncing the drag motion of two frames using jQuery

Currently, I'm developing a whack-a-mole game using javascript/jQuery. My goal is to allow users to drag the mole holes to their desired positions on the screen and then click start to begin playing (with moles popping out of the holes). However, I am ...

Using Node.js to Merge the Responses of Two Results

Here is the code snippet for fetching a list of users associated with a particular ID from this service.ts file. async getId(id: number) { // Code to retrieve participants list based on ID let participants = await this.participantRepo.findById( ...

Troubleshooting Promise resolution issue within TestBed.compileComponents in Angular 2 testing

I'm currently in the process of developing a test module for a module within my Angular2 component that utilizes the templateUrl property. As a result, I need to make the TestBed.compileComponents async call to compile before conducting any testing. ...

concise stylus CSS selector

Is there a way to condense these stylus selectors for a cleaner look? #map > div.mapboxgl-control-container > div.mapboxgl-ctrl-top-left > div:nth-child(1) > button #map > div.mapboxgl-control-container > div.mapboxgl-ctrl-top-left > ...

Unable to retrieve a specific property from a JSON object in JavaScript

I am working with a JSON object and encountering an issue. alert(typeof object) //Output Object Upon using the JSON.stringify method, I receive the following string: alert(JSON.stringify(object)); //Output object [{ "locationId":"8", "locationTypeId" ...

Utilizing custom emitted events as props for a newly created component within VueJs

My application comprises of: A component called <consl :output="output" @submit-to-vue><consl> that includes an input triggering a submit() method when the enter key is pressed. <div> <output v-html="output"></output> ...