I'm currently designing pop-up notifications for a project I'm developing. The button appears on screen, but for some reason, the pop-up feature isn't functioning as intended

`I am currently working on a game project for my class, aiming to create a nostalgic web-based choose-your-own-adventure game similar to the ones I enjoyed playing years ago. I want the experience to be challenging, where making the wrong decisions could lead to death in the game. While implementing one of these dead ends, I encountered an issue with the pop-up feature not functioning as expected. Despite verifying that the button and design elements are correctly set up, I cannot seem to pinpoint why it is failing to work. I have referred to several tutorials and resources in hopes of resolving this issue, but so far, nothing has provided a solution.

const openyoudiedbuttons = document.querySelectorAll("[data-youdied-target]")
//const overlay = document.getElementById("overlay")

openyoudiedbuttons.forEach(button => {
  button.addEventListener("click", () => {
    const youdied = 
document.querySelector(button.dataset.youdiedTarget)
    openyoudied(youdied)
  })
})

//overlay.addEventListener("click", () => {
//  const youdied = document.querySelectorAll(".youdied.active")
//})

function openyoudied(youdied) {
  if (youdied == null) return
  youdied.classlist.add("active")
  overlay.classlist.add("active")
}
.dead {color: #ca0d0d;
font-size: xx-large;
}

.youdied{
width: 300px;
top: 50%;
left: 50%;
background:black;
color: var(--red);
position: fixed;
transform: translate(-50%, -50%) scale(0);
transition: 200ms ease-in-out;
border: 1px solid rgb(134, 29, 29); 
border-radius: 10px;
z-index: 10;
width: 400px
}
.youdied.active {transform: translate(-50%, -50%) scale(1);
}

.youdied-header{
padding: 10px, 15px;
font-weight: bold;
display: flex;
align-items: center;
border-bottom: 1px solid var(--red);
}
.youdied-header .title{
font-size: 1.25rem;
font-weight: bold;
}

#overlay{
position: fixed;
opacity: 0;
top: 0;
left: 0;
right: 0;
bottom: 0;
transition: 200ms ease-in-out;
background-color: black 0, 0 ,0 .7;
pointer-events: none;
}

#overlay.active{
pointer-events: all;
opacity: 1;
}
<div class="dead">
<h1>The Pond</h1>
<img src="pond.webp"
height="300" width="600" ></div>      
<div class="youdied" id="youdied">
    <div class="youdied">You Died<br>
         As you reached for the coat. <br>
A pale hand grabs you and<br>
 pulls you under the water.
    <img src="ghosthand.jpg"
    height="150" width="250" >
<div class="box-center">
    <a href="final.html">Try Again?</a> &nbsp;</div>
</div>
</div>
<div>
<button data-youdied-target="#youdied">Grab Your Brother's 
coat</button>
</div>

I can not really say what I have tried. I have tried moving things around and making changes to my code. WHen I say I am new. I am not joking

Answer №1

Start by implementing an alert to pinpoint any errors you may have made!👍

After successful debugging, incorporate additional features to enhance your code.

Research the recommended formatting guidelines for improved readability!👍

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

What could be causing my scene to fail to render?

I'm attempting to adapt this particular example into CoffeeScript. Below is a snippet of my code: class Example width: 640 height: 480 constructor: -> @camera = new THREE.PerspectiveCamera 45, @width/@height, 10000 @cam ...

What is the process for setting up a single button selection using OR logic and multiple button selection using AND logic?

Currently working on implementing button functionality in React for filtering data. The requirement is that when selecting specific criteria, such as bedroom 3 or multiple selections like bedroom 2 and 3, the logic should vary. For instance, selecting bedr ...

Recursive array generation

Given an array 'featureList', the goal is to create a new array 'newArray' based on a specific ID. For example, for ID 5, the newArray would be ['MotherBoard','Antenna','Receiver'], where Receiver correspon ...

What could be causing a hydration error when utilizing a table in Next.js?

When attempting to use the tr tag in my code, I encountered an error message that reads: Unhandled Runtime Error Error: Hydration failed because the initial UI does not match what was rendered on the server. import React from 'react' import {useS ...

Transmit information from node.js to the frontend utilizing only raw JavaScript

Seeking guidance on sending data object from a Node.js server to a JS file for frontend use. In the main.js file, DOM manipulation is performed. The following request is made: let dataName = []; let request = async ('http://localhost:3000/') =& ...

identifies a data point from a combined dropdown menu

Is there a way to detect a specific value from a multiplied combo box? For example, when the value in one of the combo boxes changes to "2", a component is displayed. However, if the value in another combo box changes to anything other than "2", the compon ...

JavaScript validation function stopping after the first successful validation

Script: NewsletterValidation.js function formValidation() { var fname = document.getElementById('firstName').value; var lname = document.getElementById('lastName').value; var pnumber = document.getElementById('phoneNumb ...

Tips for changing the background color depending on the value

I am creating a table displaying the results of a tournament. Each team's final placement and original seeding will be listed. I plan to include a small bubble next to each team showing how their final placement compares to their initial seeding. To v ...

Error message: "An issue occurred: Unable to access undefined properties (specifically, borderRadius) in MUI react."

I recently created a navigation bar with an integrated search bar component. The styling for my search component was done using MUI styled from @emotion/styled in MUI library, where I applied a borderRadius: theme.shape.borderRadius. However, I encountere ...

What category does Ajax fall under in terms of scripting: client-side or server-side

Does Ajax fall under client-side or server-side scripting? ...

collection check_boxes = boxes for collection

Is there a way to automatically sync the checked or unchecked days in the ":committed" collection_check_boxes with the ":send_email" collection_check_boxes when a user interacts with them? For instance, if a user checks "sun" and unchecks "fri" in the "co ...

What purpose does the <noscript> tag serve in React?

Recently delving into the world of React, I've been working on a simple application by following this tutorial: https://reactjs.org/tutorial/tutorial.html. I've started modifying the code to suit my own project. While inspecting my HTML, I notic ...

Switching between languages dynamically with Angular JS using $translateProvider and JSON files

I currently have a collection consisting of 6 different JSON files. en.json es.json fr.json it.json ja.json zh.json An illustration of the data present in each file is as follows (in this instance, considering en.json): { "SomeText": "Test in Englis ...

What is the best way to retrieve specific feature properties in Open Layers 3 on-the-fly?

Within my map, I have two types: Point and Polygon, each with unique properties such as id, door number, and name. I have generated a list of features as follows: var features = new ol.format.GeoJSON().readFeatures(geojsonObject, { featureProjection: & ...

Tips for preventing the occurrence of numerous instances of braintree.setup in Angular

I am encountering an issue with a Braintree payment form displayed in a modal window: $scope.displayModalBraintree = function () { $scope.modal = 'modal_payment_form.html', $scope.$on('$includeContentLoaded', function () { ...

Using Three.js to Showcase Images within a JSON Data Structure

I am currently utilizing version 71 of the library to showcase an image on each side of a 3D object created in Blender. It doesn't matter if different images are used or if one image is repeated. The object is loaded using a load function post its ins ...

Using .css() will not change the background color

Everything seems to be working fine with the code, but for some reason, when I tried copying it over to my friend's website, the color isn't updating as it should. It's strange that it's not working now. [https://pastebin.com/jm8s6gzX] ...

Challenges in aligning images side by side within an XSLT document

My XML file is currently being transformed using XSLT to display tables, but I would like these tables to be displayed next to each other in rows of three columns. However, the current output shows them displaying one after another vertically. Here's ...

What steps can be taken in Javascript to handle a response status code of 500?

I am currently utilizing a login form to generate and send a URL (referred to as the "full url" stored in the script below) that is expected to return a JSON object. If the login details are accurate, the backend will respond with a JSON object containing ...

Can Vue/JavaScript code be transmitted within an object to a different component?

The scenario involves a parent and child Vue components. In this setup, the child component transmits data to the parent component via a simple object emitted using the emit method. Data in the child component: const Steps [ { sequenc ...