Apply a CSS class upon clicking the button

How can I use jQuery to add a class to my "infoBlock" and style its elements accordingly?

I have an infoBlock but need assistance with adding a new class.

li {
  list-style-type: none;
  }

.infoBlock {
display: block;
width: 520px;
height: 280px;
background: #fff;
margin: 50px 0 0 225px;
position: relative;

}

.infoBlock .more {
width: 180px;
height: 40px;
display: inline-block;
background: #5795f9;
text-decoration: none;
font: bold 16px Helvetica;
text-transform: uppercase;
padding: 10px ;
text-align: center;
margin: 20px 0 0 0;
color: #fff;
}

.infoBlock .person{
display: inline-block;
width: 25%;
}

.infoBlock .person img {
width: 80%;
margin: 20px 0 0 20px;
}

.infoBlock .person ul {
margin: 20px 0 0 20px;
}

.infoBlock .person .risk {
text-transform: uppercase;
color: #a6a6a6;
font: bold 15px Helvetica;
}

.infoBlock .person .level {
margin: 10px 0 0 ;
color: #ff8080;
font: bold 14px Helvetica;
}

.infoBlock .personDescription {
display: inline-block;
width: 74%;
position: absolute;
margin: 20px 0 0 20px;
}

.infoBlock .personDescription .name{
font:bold 20px Helvetica;
color: #a6a6a6;
margin: 0 0 20px;
}
.infoBlock .personDescription .position {
font: bold 15px Helvetica;
color: #5795f9;
margin: 0 0 25px;
}

.infoBlock .personDescription .description {
font: bold 14px Helvetica;
color: #a6a6a6;
}
.infoBlock .personDescription .description span {
color: #5795f9;
}
.infoBlock .personDescription .description .black {
color: #000;
}

.infoBlock .fullInfo {
display: none;
}
/* //////////////////////////// */

.infoBlock.f {
height: 480px;
}

.infoBlock.f .fullInfo {
display: block;
}

.infoBlock.f .person ul{
position: absolute;
margin: -115px 0 0 450px;

}

.infoBlock.f .personDescription .description {
display: none;
}

.infoBlock.f .border {
width: 80%;
height: 1px;
background-color: #a4a4a4;
margin: 10px 0 0 20px;
position: absolute;
}

.infoBlock.f .personDescription .more{
display: none;
}

.infoBlock.f .fullInfo {
position: absolute;
margin: 25px 0 0 25px;
}

.infoBlock.f .fullInfo .infoMenu li:hover {
color: #5795f9;
}

.infoBlock.f .fullInfo .infoMenu li{
display: inline;
margin:0 30px 0 0;
color: #a6a6a6;
font: bold 14px Helvetica;
cursor: pointer;
}

.infoBlock.f .fullInfo .scheme .schemeNumber {
margin: 20px 0 8px 30px;
font: bold 15px Arial;
color: #000;
}



.infoBlock.f .fullInfo .scheme .chance {
margin:0 0 10px 30px;
font: 16px Arial;
font-weight: 200;
color: #000;
}
.infoBlock.f .fullInfo .scheme table {
margin: 0 0 10px 28px;
}

.infoBlock.f .fullInfo .scheme table p {
font: bold 15px Helvetica; 
}
.infoBlock.f .fullInfo .scheme table .type {
color: #a5a5a5;
font: 15px Helvetica;
}

.infoBlock.f .fullInfo .scheme .problem {
font: 16px Arial;
color: #a5a5a5;
margin: 0 0 20px 30px;
}

.infoBlock.f .fullInfo .scheme .more {
margin:  0 0 0 30px;
}
<div class = "infoBlock">

      <div class = "person">
        <img src="img/1.jpg" alt = "">
        <ul>
          <li><p class = "risk">авыаыа:</p></li>
          <li><p class = "level">Висоцуацуацуаукий</p></li>
          <li></li>

        </ul>
      </div>

      <div class = "personDescription">
        <h2 class = "name">Василенко<br> Василь Антипович</h2>

        <h4 class = "position">Авыпукпуфппук</h4>

        <p class = "description">АВаываывавыпкупк <span>2х схем<br></span> на сумму більш ніж <span class = "black">3 млн. грн<span></p>
        <a href="#" class = "more" >докладніше</a>

      </div>


      <div class = "fullInfo">
        <ul class = "infoMenu">
          <li>Схеми</li>
          <li>Зв'язки</li>
          <li>Додаткова інформація</li>
        </ul>

        <div class = "scheme">
          <h3 class = "schemeNumber">Схема №1.1</h3>
          <p class = "chance">Вірогідність - 93%</p>
          <table>
            <tr>
              <td><p>Тип:</p></td>  
              <td><p class = "type">авыавыавыавыа</p></td>
            </tr>

          </table>

          <p class = "problem">Квартира площею 123 кв. м записана<br> на Василенко М.В. (теща)</p>

          <a href="#" class = "more f" >докладніше</a>
        </div>

      </div>


    </div>

Answer №1

If you want to achieve this, you can use the code snippet below:

$('.show-more').on('click', function() {
    $('.details-section').addClass('new-class');
});

Replace 'new-class' with the name of the class that contains the styles you want to apply.

Feel free to check out the live demo on Fiddle.

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

show button after the page has finished loading

I have a button similar to this: <input type="submit" id="product_197_submit_button" class="wpsc_buy_button" name="Buy" value="Add To Cart"> However, I am encountering an issue where if the user clicks the button before all scripts are loaded, an e ...

Is it possible for BufferGeometry to have material applied on just one side?

Just started experimenting with three.js. I decided to test a polygon using the code below: var geometry = new THREE.BufferGeometry(); var vertices = new Float32Array([ 2.0, 1.0, 1.0, -1.0, -1.0, 1.0, 1.0, -1.0, 1.0, 1.0, 1.0, 2.0, -1.0, -1.0, ...

Fixed position is used on elements that should always remain in the exact

I have a fixed menu on my website that is working perfectly fine. I also have a container (not using Bootstrap) that should stay fixed when it reaches the static menu. Everything is functioning as expected, except when I resize the window, the container se ...

Adding to the beginning of a list in JQuery mobile

Having trouble figuring out how to prepend my list in jQuery mobile while keeping the divider on top of the most recent item added. I attempted to prepend the newly added item, but it ended up shifting the divider to the bottom instead. function loadScan ...

The color of the links in the Bootstrap navbar refuses to budge

I'm having trouble changing the color of my navbar links to white and spacing them out evenly. I've written some code to do this, but for some reason, it keeps getting overridden. The background of the navbar is an image, and when I remove the im ...

Is JSON indicating that it's undefined?

After executing my server side code, it returns an array: return array('success'=>true, 'client_id' => $_GET['id']); The array is then echoed as follows: echo htmlspecialchars(json_encode($result), ENT_NOQUOTES); Whe ...

What is the best way to toggle the active class on a ul list?

After clicking, the active class remains on the original "li" instead of changing as it should. I've tried modifying the code but haven't been able to find a solution. Can someone please review what I might have missed? It seems like there's ...

Can you explain the process of gathering texts based on CSS selector?

I wanted to place texts next to the div-class as shown in the following code snippets. <div class="review-contents__text">소재가 좀 저렴해 보이지만 그래도 입으면 휠씬 나아보여요</div> Initially, I wrote a code ...

Creating a responsive menu that integrates seamlessly with WordPress

Currently, I am in the process of redesigning a theme that is based on the Educampus theme: Educampus I've encountered an issue where the responsive menu goes to two lines at a certain size: col-lg or col-md: https://i.sstatic.net/CbhZV.png col-sm ...

Tips for successfully sending an antiforgery token and serialized object as parameters to an MVC action

I've been attempting to pass both an AntiForgery token and a stringified serialized object to an action, but despite multiple tries, I'm still unable to do so. I have experimented with sending them as comma delimited parameters and also tried in ...

What advantages does incorporating the W3C logo into a website provide?

http://www.example.com/QA/Tools/Icons Is it necessary to add a logo to all of my personal and client sites if my code is valid? Should I include logos on client sites and inform clients that these are beneficial to have? If the code is valid but not sem ...

Use JQuery to gradually decrease the opacity of divs individually

I am currently working on a function that fades out all divs except the one that has been clicked on simultaneously. However, I want them to fade out one by one instead. Additionally, I would like the divs to fade out in a random order. If anyone knows ho ...

Fetching User Details Including Cart Content Upon User Login

After successfully creating my e-commerce application, I have managed to implement API registration and login functionalities which are working perfectly in terms of requesting and receiving responses. Additionally, I have integrated APIs for various produ ...

Problem Encountered with Position Absolute in Bootstrap 3

Could you please review this demonstration and advise me on why I am encountering issues when trying to set up an absolute position on the first row? Thank you. html, body { height: 100%; } .element{ position:absolute; top:0; } .one{height:500px; backgro ...

use jquery to send form data and display response dynamically without refreshing

Jquery: <script type="text/javascript"> $(document).ready(function(){ $("form.register").change(function() { $.post("check.php", $("form.register").serialize(), function( data ) { if( data.username == "inuse" ) ...

Enhance the elastic layout to ensure full compatibility with Internet Explorer

My elastic layout functions perfectly in Chrome and other major browsers, except for IE which seems to be ignoring the @media query. http://jsfiddle.net/U2W72/17/embedded/result/ * {margin: 0px; padding 0px'} .thumb { float: left; width:16. ...

What is the best way to format PHP emailed content from a web form?

Currently, I am working on a web contact page and facing an issue where the emails being sent arrive as plain text. I would like to enhance them by adding a background, incorporating the organization's logo, and styling the text to align with the webs ...

Retrieving information through a jQuery ajax call

I've been working on creating an AJAX filter for a car list, but I've hit a roadblock in the final stage. My setup involves two files: index.php and filter.php. Within index.php, I have a form with dropdown lists and sliders. Here's the cod ...

Incorporate HTML segments along with facilitating other JavaScript functionalities

Within my HTML file, I incorporated various HTML sections such as Header and Footer using Jquery. $(function(){ $("#leftsidebar").load("leftsidebar"); $("#topnav").load("topnav"); $("#footer").load("footer"); ...

Is it possible to create this design using Masonry?

https://i.sstatic.net/NFszG.png I have been attempting to create a grid layout like so: .grid { width: 99%; border: 1px solid #ccc; } .grid a, .grid .grid-sizer { display: inline-block; width: 20%; padding-bottom: 20%; background-size: cover; ...