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!
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

nicholas maddren
12,793 PointsjQuery - selection and checkbox element events...
Hey guys, I'm trying to find out how I can show additional content when a certain html checkbox is ticked and when a select element has been selected. I want to show additional content such as a reset button and make another select box visible.
Can I do this with jQuery if so does anyone know of any examples been browsing for a while and can't find a solution :(
Thanks
1 Answer

Hunter Cassidy
5,674 PointsYes you can do this with jQuery.
<input type="checkbox" id="my-checkbox" />
<select id="my-select">...</select>
var toggleShow = function () {
var $checkbox = $('#my-checkbox');
var $select = $('#my-select');
if ($checkbox.is(':checked') && $select.val() === "value you want") {
$('#content-to-show').show()
}
};
You would then need to decide when you want to check, on select box change perhaps?
$('#my-select').on('change', function () {
toggleShow();
});