Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial

Konrad Pilch
2,435 PointsHow to select 20 id's and classes in jQuery, and then change it's color?
If you look at this site, and every single orange thing could be changed.
Im learnign jQuery now, and i want to change all the orange things in jQuery, and set it to the color that i have clicked, if thats blue, red, pink, whatever i got.
How can i achieve it?
here Im doing or starting it, but umm, im not sure how to select it or how to do it a good way.

Konrad Pilch
2,435 PointsUh, this is as far as i got here :p please help me to figure the next step.
I made so the colros select, but how do i set the tags h2, h1 etc.. to change them the color iv just selected?
1 Answer

Steven Parker
243,134 PointsI'm not sure what you're trying to color. I didn't see any orange elements in your codepen.
But you do have the selection part working. I added a line at the end to use the chosen color to paint the background of the body.
$(function() {
var colors = $("selected"); // what is this supposed to do?
$(".color-patele li").click(function() {
$(this).siblings().removeClass("selected");
$(this).addClass("selected");
color = $(this).css("background-color"); // the chosen color is successfully assigned here
$("body").css("background-color", color); // now paint something!
});
});
It's not clear what you intended to do with the "colors" (plural) variable. The assignment won't work because you're asking JQuery to find elements of type selected (which is not an HTML element type). Did you forget to put a period (.) in front to look for the class? Even so, I'm not sure what you'd do with the result.
Just in general, when you're working out basic concepts, it will be way easier you you stick to a simple HTML. Definitely don't include any frameworks!
Eric Binmore
580 PointsEric Binmore
580 PointsYou can select the elements with something like this:
$(".text-primary, #navbar a, .portfolio-caption a, .portfolio-hover")
I don't know if that will give you all the elements you are looking for, but it's a start. Just inspect the elements that haven't been included and add them to the comma-separated list. Then you can update the
color
for the items in the list.Hopefully, that gets you started down the road to where you want to get.