Title: removeClass doesn&#039;t work, addClass does
Last modified: August 30, 2016

---

# removeClass doesn't work, addClass does

 *  Resolved [Famke__](https://wordpress.org/support/users/famke_/)
 * (@famke_)
 * [10 years, 6 months ago](https://wordpress.org/support/topic/removeclass-doesnt-work-addclass-does/)
 * Hey everyone,
 * I have a problem with jQuery. All the code I type correctly works, except when
   I call for a “removeClass”.
 * So far, I have made a tablestructure. On click, the complete first table needs
   to have an opacity of 0.5. To ensure this, I added a class called “opacity” to
   the table. In CSS, I wrote that the class has an opacity of 0.5. This works fine:
   the complete table gets the correct opacity on click.
 * However, the item that was clicked in the table shouldn’t have that opacity. 
   I tried to remove the class from the specific item, but it doesn’t seem to work.
   It only works when I try to do this for the complete table.
 * I hope someone can help me out, here’s the code:
 *     ```
       jQuery('.home_tableClick').click(function(){
       		jQuery('.home_tableEerste').addClass('opacity');
       		jQuery(this).removeClass('.home_tableEerste');
       		jQuery('#home_tableFun').load('wp-content/themes/ctaconsulting/tables.php?category='+jQuery(this).attr('id'));
       		jQuery('.initialHidden').hide();
       		jQuery('.home_tableTweede').show();
       });
       ```
   

Viewing 5 replies - 1 through 5 (of 5 total)

 *  [Rajesh Soni](https://wordpress.org/support/users/rajeshsoni/)
 * (@rajeshsoni)
 * [10 years, 6 months ago](https://wordpress.org/support/topic/removeclass-doesnt-work-addclass-does/#post-6568606)
 *     ```
       jQuery(this).removeClass('.home_tableEerste');
       ```
   
 * Try this…
 *     ```
       jQuery(this).removeClass('home_tableEerste');
       ```
   
 *  Thread Starter [Famke__](https://wordpress.org/support/users/famke_/)
 * (@famke_)
 * [10 years, 6 months ago](https://wordpress.org/support/topic/removeclass-doesnt-work-addclass-does/#post-6568619)
 * Thanks! It doesn’t seem to work, though.
 * Also, this code:
    `jQuery(this).removeClass('home_tableEerste');` is supposed
   to be: `jQuery(this).removeClass('opacity');`
 * That’s how I intended it at least. I guess I changed it to “home_tableEerste”
   because I was trying to the problem.
 * Still doesn’t work with the opacityclass and without the dot though.
 *  [Andrew Nevins](https://wordpress.org/support/users/anevins/)
 * (@anevins)
 * WCLDN 2018 Contributor | Volunteer support
 * [10 years, 6 months ago](https://wordpress.org/support/topic/removeclass-doesnt-work-addclass-does/#post-6568621)
 * If you’re having a JS issue then you need to show us the Webpage with the problem
 *  Thread Starter [Famke__](https://wordpress.org/support/users/famke_/)
 * (@famke_)
 * [10 years, 6 months ago](https://wordpress.org/support/topic/removeclass-doesnt-work-addclass-does/#post-6568631)
 * I’m running the website on localhost, so I can’t do that unless I add a screenshot
   or such.
 *  Thread Starter [Famke__](https://wordpress.org/support/users/famke_/)
 * (@famke_)
 * [10 years, 6 months ago](https://wordpress.org/support/topic/removeclass-doesnt-work-addclass-does/#post-6568779)
 * I decided to try to just add CSS to the table itself, which works. Still, I don’t
   know how to add CSS to the tableitem that I clicked, and give that item an opacity
   of 1.0.

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘removeClass doesn't work, addClass does’ is closed to new replies.

## Tags

 * [addClass](https://wordpress.org/support/topic-tag/addclass/)
 * [javascript](https://wordpress.org/support/topic-tag/javascript/)
 * [jquery](https://wordpress.org/support/topic-tag/jquery/)
 * [tables](https://wordpress.org/support/topic-tag/tables/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 5 replies
 * 3 participants
 * Last reply from: [Famke__](https://wordpress.org/support/users/famke_/)
 * Last activity: [10 years, 6 months ago](https://wordpress.org/support/topic/removeclass-doesnt-work-addclass-does/#post-6568779)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
