tags:

views:

44

answers:

2

in jquery , how can i remove a function which is already binded to a div object (named divItem1) and bind a new function with new parameters

+2  A: 

Use

unbind

This does the opposite of bind, it removes bound events from each of the matched elements.

Without any arguments, all bound events are removed. If the type is provided, all bound events of that type are removed. If the function that was passed to bind is provided as the second argument, only that specific event handler is removed.

You can also unbind custom events registered with bind.

If click event was bound to div with id 'divItem1' then you can use

$("#divItem1").unbind('click').bind('click' , function () { NewFunction(); } );

Edit

$("#divItem1").unbind('change').bind('change' , function () { NewFunction(param1, param2, ...); } );
rahul
how can i bind a function name with parameters . I have already a function definition on what to do on the change event
Shyju
+1  A: 
$('select#foo').unbind('change').change(function() {
    something('param', 2)
});

Reference

meder
updated example.
meder