Display concealed information upon clicking

Is there a way to reveal hidden content only after clicking on the "View" link instead of hovering over it?

I have tried implementing it so that the content appears on click, but it doesn't seem to be working as expected.

How can I achieve this using jQuery?

.tresc-ukryta {
    display: none;
    border:1px solid #000;
    background: #fff;
    position: absolute;
    width: 400px;
    min-height: 400px;
    top: 0;
    z-index: 50;
    border-radius: 5px;
    border: 1px solid #acacac;
    -webkit-box-shadow: 0px 0px 18px -2px rgba(0, 0, 0, 0.75);
    -moz-box-shadow: 0px 0px 18px -2px rgba(0, 0, 0, 0.75);
    box-shadow: 0px 0px 18px -2px rgba(0, 0, 0, 0.75);
}
.product-item {
    position: relative;
    border:1px solid #000;
}
.tresc-ukryta-left {
    width: 180px;
    float: left;
}
.hr-line {
    height: 1px;
    background: #acacac;
}
.tresc-ukryta-right {
    width: 190px;
    float: left;
    border-left: 1px solid #acacac;
    padding-left: 10px;
    padding-top: 10px;
}
.product-item:hover .tresc-ukryta {
    display: block;
}
.product-item:hover .pokaz-ukryta {
    visibility: hidden;
}
<div class="product-item">
<a href="#" class="title-3">Wardrobe Segment Model: SUM320<br>Dimensions: 800x400x400</a>
<a href="#" class="product-item-image"><img src="images/product-list-toplayer.jpg"></a>

<div class="price-box">
  <span class="price">Price: </span>
<span class="price-2">265 PLN</span>
<span class="price-3">NET</span>
 </div>

<div class="clearfix"></div>
<a href="#" class="view">View</a>
<div class="hidden-content hidden-xs">
<div class="hidden-content-left">
<a href="#" class="title-3">Wardrobe Segment Model: SUM320</a>
<a href="#" class="title-4">Dimensions: 800x400x400</a>
<a href="#" class="product-item-image"><img src="images/product-list-toplayer.jpg"></a>

<div class="price-box">
<span class="price">Price: </span>
<span class="price-2">265 PLN</span>
<span class="price-3">NET</span>
</div>
</div>

<div class="hidden-content-right">

<p>Description:<br>

2-segment metal wardrobe painted with powder paint. Body and doors of the wardrobe in light gray color (RAL 7035).
Doors equipped with vents. Each segment has a shelf and a clothes rail with hooks. The wardrobe is locked with a key lock with a latch in one point. .</p>

<a href="#" class="inquire">Inquire about the product</a>

</div>

<div class="clearfix"></div>

<div class="hr-line"></div>

<div class="hidden-content-bottom">

<p>Available colors:</p>

<div class="ral-hidden">
<a href="#"><img src="images/ral.jpg"></a>
<p>RAL 7035</p>
</div>

<div class="ral-hidden">
<a href="#"><img src="images/ral.jpg"></a>
<p>RAL 7035</p>
</div>

<div class="ral-hidden">
<a href="#"><img src="images/ral.jpg"></a>
<p>RAL 7035</p>
</div>
<div class="ral-hidden">
<a href="#"><img src="images/ral.jpg"></a>
<p>RAL 7035</p>
</div>
    <div class="ral-hidden">
<a href="#"><img src="images/ral.jpg"></a>
<p>RAL 7035</p>
</div>

<div class="ral-hidden">
<a href="#"><img src="images/ral.jpg"></a>
<p>RAL 7035</p>
</div>

<div class="ral-hidden">
<a href="#"><img src="images/ral.jpg"></a>
<p>RAL 7035</p>
</div>
<div class="ral-hidden">
<a href="#"><img src="images/ral.jpg"></a>
<p>RAL 7035</p>
</div>

<div class="ral-hidden">
<a href="#"><img src="images/ral.jpg"></a>
<p>RAL 7035</p>
</div>

    </div>


  </div>
</div>

Answer №1

To show the div on click instead of hover, you can utilize jQuery:

$(".Show").click(function(){
  $(".hidden-content").css("display", "block");
});

Remember to provide a way to close the div by setting it back to 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

Issue with the submission button not triggering onclick event correctly

I've been trying to add an onclick event to a submit button. I've searched various tutorial sites and followed all the suggestions, but none of them have solved the issue. Interestingly, when I include an alert in the function being called, it wo ...

Verify the functionality of the input fields by examining all 6 of them

I'm facing a challenge with a validation function in my project that involves 6 input fields each with different answers. The inputs are labeled as input1 to input6 and I need to verify the answers which are: 2, 3, 2, 2, 4, and 4 respectively. For e ...

Tips for stopping the navigator from adding content to an HTML input in an Angular application

I am facing an issue with two input fields in my Angular project. These fields are supposed to take values automatically from the browser, and I have tried using the HTML autocomplete option without success. Here is a snippet of my HTML code: <div clas ...

I am a beginner in JavaScript and I'm struggling to understand why it is not executing the else statement

As a newcomer to JavaScript, I have only learned from one website. Unsure if my code is outdated or contains elements of other software like jQuery, all I know is that it refuses to execute the else statement. <!Doctype html> <html> <body ...

Tips for integrating Server-Side Rendering into an already established React.js app running on Express.js

I am currently working on a React application and I am looking to add SSR using Express.js. Initially, I made a mistake by creating a repository with just a frontend folder containing the entire React app with typescript, babel, and webpack configurations ...

Creating a looping animation on multiple elements using jQuery that makes them fade in and out at different intervals

I am currently working on creating a fade in and out animation for multiple elements using jquery. It's a bit complex to explain, so I will start by sharing the relevant code. $(document).ready(function() { $("#1").delay(0).animate({ ...

The challenge of handling overflow in CSS slide-in and slide-out animations

Trying to achieve a smooth animation where one list of tiles moves off screen as another list comes into view. Utilizing Angular's ng-for to iterate through a visible items array, causing only one list technically despite Angular's ngAnimate mod ...

Exploring the integration of JSONP with the unmatched features of Google

I am attempting to utilize the Google maps directions API by using jquery $.ajax. After checking my developer tools, it seems that the XHR request has been completed. However, I believe there may be an issue with the way jquery Ajax handles JSON.parse. Y ...

Is it possible to close the menu by clicking outside a div or letting it disappear on mouseout after a set period of time?

When visiting a website, you may notice menus that display sub-menus when hovered over. These menus and sub-menus are created using div elements, with the sub-menus hidden initially using style.display = none; The issue arises when a sub-menu is opened an ...

What is the Vue.js alternative to setTimeout?

I'm currently in the process of developing a shopping cart feature using Laravel and Vue. In my system, when an item is added to the shopping basket, I want to display a confirmation message by toggling a Vue variable that is being monitored through a ...

Toggle the class to slide in or out of the div

I am attempting to create a header with two positions - one absolute and one fixed. I want the header to smoothly slide in as you scroll down, and then slide out when you scroll back to the top. However, I am having trouble getting it to slide; instead, it ...

What is the best way to create a point within a mesh?

I have several meshes and I'd like to insert a point randomly within the confines of hexagon[0]. How can this be achieved? var Hexagon=new Array(); Hexagon[0] = new THREE.Mesh( HexagonExtrude[0],material[0] ); Hexagon[1] = new THREE.Mesh( HexagonExtr ...

Refreshing the page in VueJs does not trigger the axios function

I've encountered an issue with my VueJs app after purchasing the Vuexy template from ThemeForest. I created a new component called CountryTable.vue, and while it works initially, it fails to display data when I refresh the page. It only shows data whe ...

Click once to reveal, click twice to conceal the slider

I currently have a web page set up so that a single click on the text displays a slider for selecting a range of values. Now, I want to incorporate a feature where a double click will remove the slider. Below is the HTML code: <!DOCTYPE html> < ...

Unraveling the Perfect Jest Stack Trace

Currently, I am in the process of debugging some tests that were written with jest using typescript and it's causing quite a headache. Whenever a test or tested class runs Postgres SQL and encounters an error in the query, the stack trace provided is ...

Pressing the enter key does not submit the Vue.js form

When attempting to submit the form by pressing "enter" on the keyboard, it only works when I click the "submit" button. I made sure to add @submit to the form event to ensure it triggers, but upon checking a log, I found that it only triggers when clicking ...

Keyframes and CSS Animation for Border Effects

I've been struggling to achieve a specific animation that I can't seem to get right. Despite searching online for solutions, none of them quite match the desired effect. What I'm looking for is a border animation that starts at the bottom l ...

Ways to extract information immediately after using the .load method

Is there a way to instantly store data from .load in JavaScript? Whenever I use .load within a JavaScript function to retrieve content from the server and display it on the browser page, the content does not update immediately. It's only when the fu ...

Discovering the smallest, largest, and average values across all properties in an array of objects

Given an array of objects with varying values, the task is to determine the minimum, maximum, and average of the properties in that array. For example, consider the following array: const array = [{ "a": "-0.06", "b": "0.25", "c": "-0.96", ...

Is there a way to use Jest spyOn to monitor a function that is returned by another function?

I'm curious about why the final assertion (expect(msgSpy).toBeCalled()) in this code snippet is failing. What adjustments should be made to ensure it passes? it('spyOn test', () => { const newClient = () => { const getMsg = ...