What steps can be followed to create functionality for having three pop-up boxes appear from just one?

I have implemented code that triggers pop-up boxes at the bottom of the screen when a user clicks on a name from a list displayed on the top right corner of the screen.

<!doctype html>
<html>
  <head>
    <title>Facebook Style Popup Design</title>
    <style>
    @media only screen and (max-width : 540px) 
    {
      .chat-sidebar
      {
        display: none !important;
      }

      .chat-popup
      {
        display: none !important;
      }
    }

    // More CSS styling...

    </style>

    <script>
    // JavaScript functions for managing the pop-ups

    </script>
  </head>
  <body>
    <script async type="text/javascript" src="//cdn.carbonads.com/carbon.js?zoneid=1673&serve=C6AILKT&placement=qnimate" id="_carbonads_js"></script>
    
    <!-- HTML markup for displaying user names -->

  </body>
</html>

Now, I am seeking to modify the functionality to display only one user name and one corresponding pop-up box in the bottom right corner. The pop-up box should close when the user clicks anywhere outside of it.

How can I implement this?

Note: I haven't provided a jsfiddle, but by copying and pasting the code into an HTML file on your machine, you can run it in your browser successfully.

Answer №1

Associate the popup with the following actions.

$(':selector').on({
            mouseover : function(){
                enterMouse = 1;
            },
            mouseout : function(){
                enterMouse = 0;
            },
            click : function(){
                enterMouse = 1;
            }
        });

        $(document).click(function(){
            if($(":selector").is(":focus")){
                enterMouse == 1;           
            };

            if(enterMouse == 0){
                $(':selector').slideUp(); 
            }
        });

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

Tips for extracting certain characters from a URL and saving them as an ID using JavaScript

Consider this scenario where I have a specific URL: http://localhost:3000/legone/survey/surveyform/form11/03141800300000030001 In order to achieve the desired outcome, I aim to extract and store different parts of the URL into designated IDs. Specificall ...

Eliminate unnecessary gaps by using HTML to position images side by side without vertical space

I am just starting out with html and css coding and recently I built my first website using wordpress. On one of the pages in wordpress, I wanted to display images next to each other with a small space between them. I achieved this successfully, but unfor ...

Submitting a Complex JSON Object through a URL with Javascript

I am attempting to send a complex JSON Object in a URL input = { "id": 1, "sd": "123", "filter": { "h": 1,"road": true }, "legs": [{ "id": 1, "x1": -0.001, "y1": 51.122 }, { "id": 2, "x1": -12, "y1": 12 }] }; I have experimented with these methods data ...

Determine a value by incrementing a number in a loop

+---+---+---+ | 1 | 0 | 0 | +---+---+---+ | 2 | 1 | 0 | +---+---+---+ | 3 | 2 | 0 | +---+---+---+ | 4 | 0 | 1 | +---+---+---+ | 5 | 1 | 1 | +---+---+---+ | 6 | 2 | 1 | +---+---+---+ | 7 | 0 | 2 | +---+---+---+ | 8 | 1 | 2 | +---+---+---+ | 9 | 2 | 2 | +--- ...

Issue encountered during Node.js installation

Every time I attempt to install node js, I encounter the following errors: C:\Users\Administrator>cd C:/xampp/htdocs/chat C:\xampp\htdocs\chat>npm install npm WARN package.json <a href="/cdn-cgi/l/email-protection" class ...

How to position the play button in the center using Material UI and Flexbox

Seeking advice on achieving a centered play button with borders in this layout. Struggling with flexbox to position the play button within the code provided. function Tasks(props) { const { classes } = props; return ( <div className={classe ...

Using the _id String in a GraphQL query to retrieve information based on the Object ID stored in a

Encountering an issue with my graphql query not returning anything when sending the _id as a string. Interestingly, querying the DB using any other stored key (like name: "Account 1") works perfectly and returns the object. I've defined my Account sch ...

Methods for transforming a TypeScript class instance containing getter/setter properties into a JSON format for storage within a MySQL database

I am currently working on a TypeScript class that includes a getter and setter method: export class KitSection { uid: string; order: number; set layout(layout: KitLayout) { this._layout = new KitLayout(layout); } get layout( ...

Styling containers with Pandoc

Currently, I am utilizing Pandoc for the purpose of transforming Pandoc Markdown documents into HTML5 documents. Within my md input, I incorporate custom divs by employing a special Pandoc syntax, like so: ::: Resources A nice document Informative website ...

Angular 2 Integration for Slick Carousel

Greetings! I have recently ventured into Angular 2 and am currently attempting to get a carousel plugin called slick up and running. After some trial and error, I have successfully implemented it as a Component in the following manner: import { Component ...

HTML5 for advanced positioning and layering of multiple canvases

I have 2 canvas layers stacked atop each other, but I need to position them relative to the entire page. The dimensions of both layers are fixed at a width of 800 and a height of 300. My goal is to center the canvas layers regardless of screen size, with ...

Initiating a function when a page is clicked using ajax requests

I'm currently working on incorporating click tracking into a page that uses ajax calls, inspired by JWPlayer's "Showcase" solution. The page consists of a listing of videos, and when a video is clicked on, the recommendations for other videos at ...

Error loading console due to JSON data on website

After creating a Json data file named question.json with the following content: "Endocrinology":[ { "title":"Endocrinology", "id": "001", "date":"08J", "question":"In adult men, anterior pituitary insufficiency does not caus ...

How can we adjust the flex values to ensure the label displays properly on a narrow container width?

The labels in the left column of the form are initially sized correctly, but shrink when there is not enough room. However, there's a discrepancy in label size between rows with 2 items and rows with 3 items. body { font-family: Arial; font-siz ...

Every Dynamic Post automatically defaults to the initial object

I am currently developing an app that retrieves feeds from a Wordpress site and displays individual posts in a jQuery mobile list format. Here is the JavaScript code I am using: $(document).ready(function () { var url = 'http://howtodeployit.com/ ...

Tips for displaying specific elements from an array by their ID when a button is clicked

I am facing an issue and need some help with my code structure. Below is the array I am working with: const countries = [ { id: 1, props: { url: '/images/polska.jpg', title: 'Polska', width: width, ...

Create a cookie on a subdomain that is accessible by all other subdomains

I have been working on a NextJS project that involves multiple apps on separate subdomains. My objective is to enable single sign-on so that when I log in to one app, I am automatically signed in to all the others. We are utilizing nookies as our cookie ha ...

Can XMLHttpRequest be exploited for XSS attacks?

Can cross-site scripting be achieved using an XMLHttpRequest as a post method? For instance, in a chatroom where users can enter text. Normally, inserting scripts like <script>alert("test")</script> would be blocked. However, you could write a ...

Modify the attributes of a CSS class according to the chosen theme (selected within the user interface) in Angular 8

I have a custom-built application with Angular 8 where users can switch between two unique themes in the user interface. I have a specific div class that I want to change the background-color for each theme, but unfortunately I am having difficulty achievi ...

Guide on configuring Angular validation to trigger on blur events and form submission

Validation in Angular is currently set to update on model change, but this method can be unfriendly for user interface as it displays errors upon keyup. An optimal solution would involve displaying error messages on blur and also on form submission. After ...