Questions tagged [toggleclass]

The toggleClass method in jQuery provides a mechanism for adding or removing a class or list of classes by name from selected elements.

The toggleClass method in jQuery provides a mechanism for adding or removing a class or list of classes by name from selected elements.

For example, if a CSS class has been applied to a div and the user wishes to remove this class from the div, the following code would accomplish this task:

theDiv.toggleClass('theClassName');

Documentation for the toggleClass method can be found in .toggleClass().

503 questions
-1
votes
1 answer

save class state of multiple divs in cookie

I have this toggleClass function: $(document).ready(function() { $("button#playersize").click(function(){ $("#wrapper").toggleClass("small large"); $(".divone").toggleClass("small large"); …
dee
  • 25
  • 5
-1
votes
2 answers

Why isn't this toggleClass() working?

I have a fairly straight-forward class toggle in jQuery. However I can't for the life of me figure out why it's not functioning as expected. When clicking anywhere on the label, the class of the

should toggle. It works as expected if you click…

Scott
  • 21,475
  • 8
  • 43
  • 55
-1
votes
2 answers

Font-Awesome icon won't change onclick

This is so simple, but I can't get it to work! On clicking a button, I'd like to change the icon in that button from fa-download to fa-spinner, but the fa-spinner just won't show up! My HTML is:
-1
votes
1 answer

Force an Off-Screen Toggle Menu to close when selecting an anchor link?

The Javascript solution I'm looking for should accomplish the following: Toggle open Offscreen Toggle menu Select an anchor tag menu link, which navigates to the anchored section on the same page The toggle menu closes This is the full code Fiddle…
ChosenJuan
  • 891
  • 3
  • 26
  • 56
-1
votes
2 answers

Why not toggle classes in jQuery?

I created a little sketch to testing my knowledge. I would like to change classes by click on td elements. I added a basic class and after i'd change with toggleClass(). Unfortunately doesn't works. $( function() { …
user5439948
-1
votes
1 answer

jQuery toggleClass - Only working with the first ID selector

I would like to create one of those read more / read less buttons using toggleClass(). This is my html:

Lots of bla bla bla.....Plus

Lots of bla bla bla.....Plus

Lots of bla bla…

William
  • 421
  • 3
  • 6
  • 17
-1
votes
1 answer

How do I use Cookie.js to load a page differently based on previously visited pages

I've been unable to figure out the right way to implement this mainly because of syntax issues as I'm fairly new to all of this. I'd like to check if a user has been to a certain page (page2). I've got this script: