The color of the last clicked DIV is supposed to stay permanent, but for some unknown reason

I'm attempting to replicate this design in my project: http://jsfiddle.net/AYRh6/26/ However, I am facing issues with it and cannot pinpoint the exact problem in the code. I am using code for a toggle effect.

Any assistance would be greatly appreciated.

Link to my issue: http://jsfiddle.net/Gr8sw/

Here is my HTML:

    <div id="category">
         <section id="pushOne" class="slidebox">
        <div class="toggle>
            <a class="bot" href="#"><img src="01.png" alt="Category 1"/></a>
                <a class="top" href="#pushOne"><img src="01.png" alt="Category 1"/></a>
        </div>
        <div class="box"><h2>Category 1</h2>   
            Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin facilisis aliquet odio, dictum hendrerit metus egestas non. Ut quis est tellus. Duis luctus elit nec arcu bibendum lacinia. Quisque luctus orci lorem, sit amet consequat enim mollis quis. Nullam dui magna, aliquam non venenatis et, lobortis eget felis. 
            </div>
         </section> 
</div>

And here is my CSS:

.toggle {
    height:230px;
    width:230px;
    position:relative;
    z-index:2;
    background:#CECECE;
}

.toggle:hover, .toggle.clicked {background:#F05A24;}

.orange {background#F05A24;}

.toggle img {width:100%;}

#pushOne img {padding-top:20px;}

.toggle a { position: absolute; padding:40px;}

.box {
    overflow:hidden;
    display:hidden;
    opacity:0;
    transition: all .4s ease-out;
    margin-top:0px;
    margin-bottom:20px;
    width:230px;
}

.slidebox:target .box {
    min-height:100px;
    opacity:1;
}

.slidebox {float:left; margin:0 50px 0 0; transition: all 0.2s ease;}
.slidebox:target .top { opacity:0; pointer-events: none;}

#category {margin:0 auto;width:80%;}

Javascript:

$(".toggle").click(function () {
   $(this).toggleClass(".clicked");
});</script>

There's something elusive that my eyes are missing :(

Answer №1

You haven't specified any CSS properties for the class "clicked" (the class you want to toggle into).

Remember to remove the dot (.) before the class name.


$(".toggle").click(function () {
    $(this).toggleClass("clicked");
});

Make sure to include the external jQuery source by visiting here.

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

Ways to showcase corresponding information for an item contained within an array?

I'm working with a function that is designed to retrieve specific descriptions for objects nested within an array. The purpose of the function (findSettings()) is to take in an array (systemSettings) and a key (tab12) as arguments, then use a switch s ...

Transforming the initial character of a label element into uppercase

When I receive an external HTML page, all the data comes in lowercase. I attempted to capitalize the first letter of each label tag using CSS, but it ended up making the entire text uppercase instead. Here is what I tried: .fontmodal { text-transform ...

Is there a way to eliminate the menuArrow from a Select widget in gwt-bootstrap3?

In my current project, using gwt-bootstrap3, I have been attempting to conditionally remove the menu arrow from a Select box. I have experimented with various methods such as: <select:Select ui:field="fieldName" name="fieldName" b:id="fieldName" showM ...

SequelizeDatabaseError: The operation could not be executed as there is no operator that allows for

I am attempting to create a join between two tables using UUIDs (also have IDs), and the relationships between these tables are quite complex... However, I encounter an error when running the query. The first table is named users, with its UUID labeled a ...

The object filtering process is experiencing issues due to the presence of a null value in the column

I am trying to extract object data based on a specific value from an array. While the code snippet below works well when there are no null values, it fails to work properly when encountering null values in the column. For reference, you can check out this ...

What is the most efficient way to save a document in mongoose based on a specific user's

Is there a way to ensure that when saving a template, it is associated with the user id? I have added a reference to the templateSchema for the User. User.model.js var UserSchema = new mongoose.Schema({ _id: { type: String, required: true, index: {uniq ...

The inputs for Node express middleware are unclear and lack definition

I am currently exploring Node.js as a potential replacement for my existing DOT NET API. I have created middleware to enforce basic non-role authorization in my application, but I am encountering compilation problems with the function inputs. Compilation ...

The JQuery click() function may fire twice if triggered by the live() method

http://pastebin.com/1MGTtzij is where you can find my complete HTML document. Here's a condensed version: $(document).ready(function () { $("#myDiv").append($("<input />", { type : "button", ...

The Firebase JQuery .on method is incrementally updating individual values in an array instead of updating them all simultaneously

I am trying to update the values of the orders placed by users on the Corporate's page without a refresh. I have implemented the jQuery .on method for this purpose. However, the values are being returned one by one from the array created for the order ...

Angular2 Window Opener

Trying to establish communication between a child window and parent window in Angular 2, but I'm stuck on how to utilize window.opener for passing a parameter to Angular 2. In my previous experience with Angular 1.5, I referenced something similar he ...

Troubleshooting PhantomJS hanging with WebdriverJS tests on Windows

I am currently using webdriverjs to run automated tests on a Windows 8 system. The tests run successfully when the browser is set to Chrome, but encounter issues when I switch to PhantomJS. Interestingly, the same tests run smoothly on OS X Mavericks. Ins ...

premature submission alert on button press

I'm encountering an issue where my form is being submitted prematurely when I click on the button. The desired behavior is for the button to create a textarea upon clicking, allowing me to write in it before submitting by clicking the button again. Ho ...

Contact on the go with our handy mobile contact form

Having some difficulties with the contact form on my website. The link to the form is: here. I am currently working on making the form mobile-friendly (the rest of the site scales down using @mobile screen tags in the CSS). The form is stacked, so there ...

Alternative way to search for child elements within an element without the use of jQuery

I am in the process of creating a universal set of functions to verify the existence of children with specific attributes within a particular element. Unfortunately, I do not have access to jQuery for this task. Here is an example function call: has_chil ...

Step-by-step guide on using nodemon on a web hosting server

I am currently designing a website that includes a login form and I am in the process of uploading it to a web hosting service In order to activate my login form, I have to use node index Is there a way to change the destination of this tag: <li class ...

What are the steps to create an endless scrolling feature?

I'm trying to create a slider with a horizontal scrolling effect, but I've hit a roadblock. How can I make the slider scroll infinitely? In my code, you can see that after Item 6, it stops scrolling and I have to scroll backward. However, I want ...

Updating a Div with XML data through JQuery

Hey everyone, I have a simple question that I need help with... Currently, I am using jQuery to retrieve an XML document in the following format: $.ajax({ type: verb, url: url, dataType: datatype, success: callback }) } After receiving t ...

dynamic jquery checkbox limit

I am working with the following HTML code: <input type="checkbox" id="perlengkapans" data-stok="[1]" onchange="ambil($(this))"> name item 1 <input type="checkbox" id="perlengkapans" data-stok="[4]" onchange="ambil($(this))"> name item 2 &l ...

What is the best way to ensure that the columns are the same height, regardless of the varying content they contain

Visit my CodePen For this particular layout, I need to use only CSS. The columns are structured like so: <div class="col-md-12 no-border no-padding"> <h2 class="heading upper align-center">Headline</h2> <p class="subheading lower ...

Steps to establish a maximum font size for my buttons

I've been working on creating buttons to decrease and increase the font size of my text. The functionality is there, but I want to establish a limit on how small or large the font can go. Here's what my current code looks like: <md-button ng ...