Skip to main content
Legend
January 2, 2020
Question

Experts: An interesting one to solve????

  • January 2, 2020
  • 1 reply
  • 1652 views

Whilst helping out in another thread today I wanted to toggle a Fontawesome icon - fa-bars to fa-minus. Usually swapping Fontawesome icons is a no brainer using javascript toggle, as in the example below:

 

https://www.w3schools.com/howto/tryit.asp?filename=tryhow_js_toggle_like_dislike

 

Try it with fa-bars and fa-minus - why doesn't it work like the example which toggles fa-thumbs-up/fa-thumbs-down???

 

Edit

Although it work the other way around toggling fa-minus to fa-bars..........

 

Maybe I'm still too full of beer.

This topic has been closed for replies.

1 reply

Jon Fritz
Community Expert
Community Expert
January 2, 2020

Weird, fa-minus-square works fine, but fa-minus is a no-go.

Something conflicting within W3schools site maybe?

osgood_Author
Legend
January 2, 2020

Nope not a fault of the W3 schools website, I did a local test and looked in the console - the class is being applied 'fa fa-bars fa-minus' but it doesnt change to a minus icon, whereas if I used the fa-thumbs-up or fa-thumbs-down class the icon changed.

 

To get it to work I had to check to see if the class list contained fa-bars, remove it if it did and apply fa-minus but that's not as simple/streamlined as just toggling the class.

 

No idea why its not working, madness.

 

B i r n o u
Legend
January 3, 2020