Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

JavaScript

jQuery: How to fire event when an option is selected?

I have a select tag with a few option tags nested inside. I have a few seperate divs on the page that are initially hidden when the document loads.

How could I use jQuery to fire an event that shows certain divs when their corresponding option is selected? Is this possible with jQuery?

1 Answer

Kevin Korte
Kevin Korte
28,110 Points

I'm pretty terrible and JS and Jquery, but I built something stupid that functions. I'm sure there is likely a better way to do it, but this will hopefully at least give you an idea.

http://codepen.io/kevink/pen/vzDqp

Thanks, I built on this and I have exactly what I need now!

Kevin Korte
Kevin Korte
28,110 Points

Awesome! Glad to hear. It was a fun challenge for me too.