Issue with Clicking Mouse to Display Content not Operational

I need a way to make a div element hidden until the user clicks on it, at which point it should be displayed.

HTML

<div class="coupon-wrapper">
    <a href="/{{ i.couponStoreURL }}/#{{ i.id }}">
        <span id="couponCode" style="">{{ i.couponCode }}</span>
    </a>
    <span class="click-to-see">Click to reveal code</span>
</div><br><br>

CSS

.coupon-wrapper {
    height:50px;
    width: 175px;
    position: relative;
    display:inline-block;
    border:1px dashed;
    padding:5px;
    margin:5px;
    background:#EE4000;
    color:white;
    text-align:center;
}

.click-to-see {
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    opacity: 0;
    height:30px;
    width: 185px;
    line-height:4em;
    background: black;
    visibility: visible;
    position: absolute;
    -webkit-transition: visibility opacity 0.1s;
}

.coupon-wrapper:hover .click-to-see {
    opacity:1;
    color:white;
    visibility: hidden;
}

.coupon-wrapper a {
    color:white;
    text-decoration:none;
}

Answer №1

After reviewing your CSS/HTML, it appears that you will need to incorporate some Javascript.

$('.cTs').on("click", function() {
    $(this).css("opacity", 0).delay(100).queue(function() {
        $(this).css("display", "none");
    });
});

The inclusion of delay/queue functions in the script is necessary for ensuring that the span remains hidden until the animation has completed. While there are more appropriate methods available, this should suffice for now.

Is this similar to what you were looking for? http://jsfiddle.net/ninty9notout/3EMv2/

Answer №2

Here is one potential answer to your query:

.cTsdiv:hover .cTs {
opacity:1;
color:white;
display:none;
}
.cTsdiv:active .cTs {
opacity:1;
color:white;
display:block;
}

Answer №3

Give this a shot

$(document).ready(function(){
$('.cTsdiv a').click(function() {
    $(this).next('.cTs').fadeIn();
    return false;
});
});

I've also made some modifications to your CSS

Check out the jsfiddle File

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

Incorporating server-side rendered components into a Vue.js parent component

I have a server-side rendered page that includes information about "orders" and a root Vue object initialized as the "parent object." Is it feasible to assign the rendered HTML orders as children of that parent Vue object? Vue.js is known for its dynamic ...

What is the best placement for video content in a website development project?

Storing images in a folder named images is recommended for better website organization and SEO benefits. But what about local video content? Should it go in a folder labeled videos? ...

How can I use BS4 in Python to extract specific text?

When working with BS4, I am trying to isolate specific text. A snippet of the provided HTML is shown below. </tr><tr id="_Gonzaga" class="seedrow"> <td title="Click to show/hide ranks" class='lowrowclick' style="text-align:cente ...

A guide on using jQuery to iterate through 3 separate div elements

Seeking assistance with creating a dynamic loop for multiple divs (3 or more) using jQuery. The desired outcome is to have the main image div on the homepage rotate with other divs, changing both the background image and links within each div. I initially ...

Link not functioning correctly on mobile-responsive CSS

Having some trouble with hyperlinks over a background image. The hyperlinks work fine normally, but in mobile view, nothing happens when clicking on them. Below is the code for the hyperlinks. You can also visit the site and see that the "Post a Project" ...

Transparent CSS Table Styling

Can you create a CSS effect where all content inside a table becomes transparent on hover? For example: <table><tr><td> AN IMAGE </td> <td> SOME TEXT </td></tr></table> So if either the image or the text ar ...

How can I use CSS to ensure that both cards and images are equal in size?

I am currently utilizing react, with Material-ui being used for the Cards. For the layout, I have implemented CSS Grid Layout for the Grid system. Presently, the structure looks like this: https://i.stack.imgur.com/0FDyY.png However, my desired outcome i ...

Selenium - How to effectively obtain hyperlinks?

There are numerous web elements similar to this example <a data-control-name="browsemap_profile" href="/in/quyen-nguyen-63098b123/" id="ember278" class="pv-browsemap-section__member ember-view"> <img widt ...

As I navigate through Chrome's inspect tool, I notice that certain elements are overlapping

https://i.sstatic.net/kwlIM.png After opening Chrome, I noticed that some elements are overlapping. This issue can be seen in the image provided. How can I resolve this problem? ...

What is the best way to create a read-only input field?

https://i.sstatic.net/36h6s.png The code I attempted to use did not produce the desired result <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="91f3fefee5e2e5e3f ...

Leverage the power of the General Sibling Selector to easily traverse through deeply nested elements in your

Hi there, I have a query regarding the General Sibling Selector. Let's start by looking at the HTML: <div id="layout-middle"> <div id="Center"> <a class="col Picture1">Title1</a> <a class="col Picture2">Title2< ...

Looking to include a toggle button in the menu for both desktop and mobile versions using Bootstrap

When viewing the website on a mobile device, the menu appears as a toggle button. However, on desktop, the menu is displayed without the toggle. Is there a way to show the menu in a toggle button on the desktop version using Bootstrap? ...

Designing Material UI Button Styles

Hello, I recently started using Material UI and I'm facing some challenges in styling the components. Right now, I'm working on a sign-in page and trying to position the Submit button all the way to the bottom right corner. Any help or advice wou ...

Placing a moveable object in a designated spot for dropping at the desired location

I've been attempting to clone and drop a draggable object at the exact position within a droppable area where the drop event takes place. While I have come across examples online that demonstrate appending draggables to droppables, they all tend to re ...

"Utilizing Bootstrap to add borders to div elements is a

https://i.sstatic.net/yPt46.png Hey there! I am working on a project using bootstrap 4. I encountered an issue that I can't seem to solve. I placed an image inside a div, set the div's height and width to 200px with overflow hidden. The image w ...

Making poll everywhere items align horizontally using HTML: a step-by-step guide

Is there a way to display two different Poll Everywhere polls side by side on a Blackboard course, rather than having them stacked on top of each other? I have the embed codes for both polls ready to go. ...

When you initiate a prevent default, both the Angular and Bootstrap UI tabs will become active simultaneously

I am facing a CSS issue while utilizing Angular UI-Tab. The problem arises when I have two tabs and need to stop tab switching based on a specific condition. To achieve this, I implemented prevent default. However, the CSS displays both tabs as active bec ...

GWT 2.5.1 - How to Restrict the Amount of Items Displayed in a Dropdown Menu (ValueListBox)

Currently, I am utilizing a ValueListBox to showcase a range of values for users to choose from. The main issue I am encountering pertains to IE11 and its subpar behavior when interacting with the control: The dropdown list appears all over the place (in ...

What is the best way to merge a card-deck with fixed-width cards?

Currently, I am using flex-mode and aiming to create a 'deck' of 'cards' with uniform height and width. My goal is to ensure that the width remains consistent across different breakpoints. Unfortunately, I have not been able to achieve ...

Conceal the countdown clock and reveal the message box

I am attempting to create a functionality where the text box will replace the timer when it reaches 0, and then the timer will be hidden. I am seeking a straightforward solution using either the 'v-show' or 'destroy' property in vue.js ...