Question: Say I have 2 Javascript files, `includeFirst.js`, and `includeSecond.js`, which are loading into the page. IF the first contains some code like:

```
$('#myButton').click(function() {
   alert('Hello World');
}

```

And the second contains:

```
$('#myButton').click(function() {
    alert('World Hello');
}

```

I'm getting both alerts popping up. Is there any way I can add something to the .click in the second so that the first doesn't run?

I realize this coding method seems sloppy/bad, but it's just to fix a bit of legacy code that will be fully rewritten soon. I'd just like to fix this temporarily.

Answer: 
Unbind existing event handlers
------------------------------

You should unbind any existing event handlers and then bind a new one. but beware that this may have undesired effects when existing event handlers do something vital and new ones don't replicate this behaviour.

```
$("#myButton")
    .unbind("click")
    .click(function(){
        alert("Hello world");
    });

```

I've chained these calls so it will first unbind any existing *click* event handlers (and **all of them** when there are several) and then bind a new one...

Unbinding particular event handlers of the same type
----------------------------------------------------

If you'd like to unbind only particular event handlers of the same type, you can use [event namespaces](http://api.jquery.com/bind/). They have the form of `click.namespaceName`

> 
> **jQuery `.bind()` Docs:**  
> 
>  If the *eventType* string contains a period (.) character, then the
>  event is namespaced. The period character separates the event from its
>  namespace. For example, in the call `.bind( "click.name", handler)`,
>  the string *click* is the event type, and the string *name* is the
>  namespace. Namespacing allows us to unbind or trigger some events of a
>  type without affecting others.
> 
> 
>
try using event.preventDefault() in your second click event