MR.Don't know MR.Don't know - 1 year ago 123
jQuery Question

Reverse click jquery

When I click on a class

, my code adds a new class
which adds an overlay. But when I click a second time, nothing happens and class remains active.

Upon the second click on
, I want to return to the starting position, then on every click is changing class.

How can I achieve this?

$(function($) {
$(document).on('click', '.box-btn', function(event) {
var target = $('.wrapper');
target.find('.box-title, .box-text').addClass("full");

Answer Source

Try using toggleClass() instead so it removes those classes on second click

target.find('.box-title, .box-text').toggleClass("full");
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download