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![](https://ecs-static.teamtreehouse.com/assets/views/marketing/shared/community-banner-white-47072046c51352fe6a69f5e691ff5700b28bb11d45197d7bdf066d9ea3f72d0c.webp)
![Tushar Singh](https://uploads.teamtreehouse.com/production/profile-photos/5657532/micro_37016_572954962737694_284191630_n.jpg)
Tushar Singh
Courses Plus Student 8,692 PointsPlease help!!!!!!
http://codepen.io/tushar_13/pen/ZWvOwg
I tried many things and none of them worked. I want that if i click the online button, only show that channels which are currently streaming and same is the case with the offline button.
Please can someone take a look at my code in codepen and suggest what should I do.
Thanks!
6 Answers
![Samuel Key](https://uploads.teamtreehouse.com/production/profile-photos/5198252/micro_jennyLake.jpg)
Samuel Key
3,310 PointsI messed around with your codepen a bit. Give this a try:
// working on buttons
$('#online').click(function(){
$('#main-section li').each(function() {
if($(this).find($('span')).hasClass('online')){
$(this).show();
}else {
$(this).hide();
}
})
});
$('#offline').click(function(){
$('#main-section li').each(function() {
if($(this).find($('span')).hasClass('offline')){
$(this).show();
}else {
$(this).hide();
}
})
});
I think that accomplishes what you are looking for.
![Tushar Singh](https://uploads.teamtreehouse.com/production/profile-photos/5657532/micro_37016_572954962737694_284191630_n.jpg)
Tushar Singh
Courses Plus Student 8,692 PointsI figured it out but your answer is kinda better and short basically Mine--
$('#all').click(function() {
$('.sub-section').css('display', 'block');
});
$('#offline').click(function(){
$('.sub-section:contains("Online")').css('display', 'none');
$('.sub-section:contains("Offline")').css('display', 'block');
});
$('#online').click(function(){
$('.sub-section:contains("Offline")').css('display', 'none');
$('.sub-section:contains("Online")').css('display', 'block');
});
![Tushar Singh](https://uploads.teamtreehouse.com/production/profile-photos/5657532/micro_37016_572954962737694_284191630_n.jpg)
Tushar Singh
Courses Plus Student 8,692 PointsThanks man and you should post your answer in the answer section, not as a comment. Now I can't choose your answer as the best answer.
![Samuel Key](https://uploads.teamtreehouse.com/production/profile-photos/5198252/micro_jennyLake.jpg)
Samuel Key
3,310 PointsOops, I always do that
![Steven Parker](https://uploads.teamtreehouse.com/production/profile-photos/969492/micro_tool_chess_set_2.jpg)
Steven Parker
230,688 PointsI couldn't tell that the buttons were doing anything right now. So I added click handlers to them:
// this goes in the "ready" area:
$("#all").click(function() {
$("span.online,span.offline").parents("li").show();
});
$("#offline").click(function() {
$("span.online").parents("li").hide();
$("span.offline").parents("li").show();
});
$("#online").click(function() {
$("span.offline").parents("li").hide();
$("span.online").parents("li").show();
});
});
![Tushar Singh](https://uploads.teamtreehouse.com/production/profile-photos/5657532/micro_37016_572954962737694_284191630_n.jpg)
Tushar Singh
Courses Plus Student 8,692 PointsOh ya parents, I should have thought of that. Thanks bro again. You saved my ass twice. ;)
![Steven Parker](https://uploads.teamtreehouse.com/production/profile-photos/969492/micro_tool_chess_set_2.jpg)
Steven Parker
230,688 PointsHeh, I got distracted while I was composing that. I see while I was doing it you got a somewhat similar answer, but with interesting differences. Just goes to show how much variation you can have in programming.
![Tushar Singh](https://uploads.teamtreehouse.com/production/profile-photos/5657532/micro_37016_572954962737694_284191630_n.jpg)
Tushar Singh
Courses Plus Student 8,692 PointsThanks again. Here I have noticed that people do not answer your questions. They just want to answer those stupid and super easy challenges. I really appreciate your help. I was stuck for a long time, I am not aware of this "find"; I'll look into it.
![Samuel Key](https://uploads.teamtreehouse.com/production/profile-photos/5198252/micro_jennyLake.jpg)
Samuel Key
3,310 PointsSure thing! Looks like a cool site you're building.
![Steven Parker](https://uploads.teamtreehouse.com/production/profile-photos/969492/micro_tool_chess_set_2.jpg)
Steven Parker
230,688 PointsI actually enjoy the more challenging questions (assuming it's *technically" challenging , not one of those that are just hard to understand!
).
![Tushar Singh](https://uploads.teamtreehouse.com/production/profile-photos/5657532/micro_37016_572954962737694_284191630_n.jpg)
Tushar Singh
Courses Plus Student 8,692 PointsHaha me too, I'm in love with programming. Everything is logical and makes sense. Challenges are actually fun that's why I chose to do something on my own rather than just watching videos and solving their super easy and dumb questions.
I think we will definitely meet on the forum again. Now I think I understand how to work with an api and it's time to move up the ladder.
Next thing on my list is a javascript calculator.
Samuel and Steven I think I will bug you again :p
![Tushar Singh](https://uploads.teamtreehouse.com/production/profile-photos/5657532/micro_37016_572954962737694_284191630_n.jpg)
Tushar Singh
Courses Plus Student 8,692 PointsPlease head over to this page
https://teamtreehouse.com/community/a-little-problem-with-objects