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

JavaScript

ana s
ana s
1,574 Points

Is it necessary to bind the event? What does that actually do in plain english?

I practiced without using this:

  //Bind change listener to the select
  $select.change(function(){
    //Go to select's location
    window.location = $select.val();
  });

and it worked. So I am not sure why the bind is necessary. Can you explain "binding" and then "unbinding"? Can you also provide a real world example where you would "bind" and then "unbind"?

Thanks!

2 Answers

Andrew Chalkley
STAFF
Andrew Chalkley
Treehouse Guest Teacher

Binding to an event means to attach a piece of functionality to an event. If you don't bind, nothing will happen.

A scenario where you may want to "unbind" or stop listening for an event would be if you didn't want something to be editable anymore.

ana s
ana s
1,574 Points

Thanks, Andrew. I think I got confused because I've seen the word "bind" as part of a function. Maybe I mis-remembered ...