Would this work? FCC "Remove Classes from an element with jQuery" Challenge

for “Remove Classes from an element with jQuery” Challenge.

$("#target1").removeClass("btn-default");
$("#target6").removeClass("btn-default");
$("#target5").removeClass("btn-default");
$("#target2 ").removeClass("btn-default");
$("#target3").removeClass("btn-default");
$("#target4").removeClass("btn-default");

can this be changed to this

$("#target1 #target2 #target3 #target4 #target5 #target6").removeClass("btn-default");

I thought it was the same thing.

I cleaned up your code.
You need to use triple backticks to post code to the forum.
See this post for details.

The challenge is to remove the class from all of your button elements, so I advise targeting them by that rather than by id.

To answer your question though, you can target multiple identifiers in jQuery but you need commas. Always check the documentation.

1 Like