Popup modal experiencing technical difficulties

As part of my college project, I am creating a website and have hosted it on a free hosting site to showcase. You can view the site here. In the informal section of the menu, I wanted to include a pop-up modal. Here is the code snippet for reference: http://jsfiddle.net/karn21/73QXx/.

When you click on "Click Me," it should trigger the modal below:

   <div id="openModal" class="modalDialog">
<div>

    <a href="#close" title="Close" class="close">X</a>
    </div>
    </div>

However, there seems to be an issue with the functionality on click. Any assistance would be greatly appreciated.

Answer №1

If you don't want to set it as a target, consider adding an onclick event for the button labeled Click Me. This event can trigger a JavaScript function that appends the id target to the div (or another class). After that, modify .modalDialog:target to .modalDialog.target. Finally, simply remove the class when the close button is clicked.

Check out the updated Fiddle here: http://jsfiddle.net/73QXx/2/

This change should not affect your hashtag scrolling script at all.

If you still prefer the appearance of a link, you can include this CSS:

a {
    color: #0645AD;
    text-decoration: underline;
    cursor: hand;
    cursor: pointer;
}
a:visited {
    color: #663366;
}

EDIT:

Note that the following line is supported only by IE11+:

pointer-events: none;

For compatibility with IE10 and lower versions, you can use this alternative approach using z-index:

pointer-events: none; => z-index: -1;
pointer-events: auto; => z-index: 10; /*This value may need adjustment based on other elements in the page*/

Here's an updated Fiddle specifically for IE9 compatibility (as well as older versions): http://jsfiddle.net/73QXx/3/

However, keep in mind that using this approach outside of IE9 or below could result in a sudden appearance of the box instead of a smooth fade-in effect.

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

Using jQuery to create radial-gradients with the background-css feature

I'm a newcomer to this online community and English is not my first language. Despite that, I will do my utmost to clearly explain the issue at hand. Recently, I utilized the .css function in jQuery to create a design element successfully. However, I ...

Is it feasible to customize the appearance of output text to resemble that of a password input field in Rich Faces?

Within our dataTable, we have a collection of attributes. Included in these are outputtext fields that contain passwords. Typically, password fields display as a series of black bullets if they are input fields (inputSecret). Currently, the outputText fi ...

Steps to resolve the 'Unknown keyword' issue while packaging a CSS file using webpack

In the process of upgrading dependencies to the latest versions for my Electron app built in Angular, I have encountered some issues. ✅ Electron remains on v19 ✅ Tailwindcss is updated to v3.1.8 ⬆️ Angular is being upgraded from v11 to v14 ⬆️ ...

New design for UI grid: eliminate sorting menu and right-align column headers

I came across a question similar to this one My goal is to eliminate the dropdown menu from the column headers and align the text of the headers to the right. .ui-grid-header-cell { text-align: right; } However, my current attempts result in the disap ...

The submit button click does not trigger the execution of ajax code

I'm faced with a challenge when trying to implement an ajax call in my form. My goal is to display a spinner on the screen to indicate that the form is processing and submitting information. However, it seems that the ajax call is not being triggered ...

Customize the default styles for Angular 2/4 Material's "md-menu" component

Seeking to customize default styles of md-menu in Angular Material. The challenge lies in the dynamic generation of elements by Angular Material, preventing direct access from HTML. Visual representation of DOM: https://i.sstatic.net/v8GE0.png Component ...

What steps should I take to modify the URL using the SELECT tag?

Having a bunch of SELECT tags in place <select id="url"> <option id="url1" >url 1</option> <option id="url2" >url 2</option> </select> <button onclick="go()">GO</button> Followed by the associated scrip ...

"Creating a distinctive CSS style for underlining titles without including the actual

Although I've searched on SO, I still haven't found a satisfactory solution to my question. So here's the issue: I want to underline an h3 tag with 100% width EXCEPT for the actual text part. It should look like this: My super title ...

Unable to correctly declare and display UTF-8 character within JSON syntax

In my JSON object, there is an attribute that contains a unique special character - I've attempted to save the string in encoded UTF-8 as "\xF0\x9F\x94\x94" or tried displaying it using its HEX value - String.fromCharCode(0x1F514 ...

Tips for ensuring your webpage stays current with regular updates through JavaScript

This webpage acts as a dynamic newsboard, constantly updated with the latest data from my Database through an API, all without requiring a page refresh. While the timer solution seemed simple, I am seeking a more resource-efficient approach. I have resear ...

Can you provide guidance on how to showcase the chat date and time for each message in a webchat created with the bot framework SDKV4 using C#

I've successfully created a chatBot using bot framework SDKV4 in C# with the WebChannel as the channel. Everything is functioning properly, but I have a specific goal in mind: For each message that the user types or the Bot replies to, I want a time ...

What is the method for saving background color and font size preferences in local storage using HTML?

I want to give visitors to my site the option to customize the background color and text size. Can their preferences be saved in local storage? If so, could you share some HTML code to make this possible? ...

The PhoneGap Android whitelist feature seems to be malfunctioning and preventing navigation to the next page

Currently, I am utilizing the jQuery function load() with the code snippet $('#result').load('http://.... #div'); to retrieve the content of an external website. Moreover, I have made modifications to the domain whitelist specifically f ...

Restrict printing loops within the designated division layer

Is there a way to limit the number of rows displayed horizontally when using foreach? I only want to display 7 rows. Can this be achieved with CSS or pagination? Here is an image illustrating the issue: https://i.sstatic.net/yJx3N.png Currently, it print ...

"When the DIV is hovered over, 3 items are displayed, 3 items are concealed, and there is one

Within my design, I have three main boxes identified as #box1, #box2, and #box3. The goal is to reveal the hidden information text, labeled .info1, .info2, and .info3 respectively, when hovering over each box. Simultaneously, the opacity of the other boxes ...

SVG fill with no color

Currently, I am attempting to utilize a wave SVG while also having a background image set for the body of the webpage. However, I am encountering an issue where I want the SVG to be filled with transparency so that the body background image shows through. ...

When a selection element has a CSS box-shadow animation applied to it, it reverts to its default settings when expanded or clicked

A user notified me of an issue with a select element that has an animated box-shadow on it. I confirmed the problem on my work Windows computer, but unfortunately, I don't have access to a Windows setup at home for debugging. The select element in qu ...

Adjusting the repeating-linear-gradient CSS background

My goal is to make adjustments to a specific CSS code, in this case it is the repeating-linear-gradient. Take a look at my current implementation: input[type="range"]::-moz-range-track { background: repeating-linear-gradient(to right, #ccc, # ...

Unable to place a div below another div

I am in the process of creating a website for my mother, using my limited knowledge. Despite numerous attempts, I have not been able to achieve the desired outcome. Currently, the website looks like this: https://i.stack.imgur.com/ItOcp.jpg However, I e ...

Eliminating inline JavaScript code

Hello everyone, I need some help with my website. I have a series of image comparisons and I've currently used inline JS to manage them. However, as the number of comparisons has increased, I realize that inline JS is not the best solution for this. C ...