Reputation: 1085
I am facing problem while unbinding the event using JQuery.
$(document).ready(function() {
$('#tdMinPriceOnNonStop0').unbind("click");
});
Its Not Working..
<td class="tddat matrixCellHt" align="center" onclick='javascript:DoHighlighting("tdMinPriceOnNonStop",<%#Container.ItemIndex%>);FilterResults("SingleAirlineParticularStop","0&<%#((string)DataBinder.Eval(Container.DataItem, "AirlineDisplayName"))%>")' id="tdMinPriceOnNonStop<%# Container.ItemIndex %>"
Upvotes: 0
Views: 194
Reputation: 23570
go for
$('#tdMinPriceOnNonStop0').removeProp("onclick").removeAttr("onclick");
Because the event handler is stored directly in the element's property rather than in jQuery's $.data object (where jQuery stores all its handlers) you can't use jQuery's unbind method (removeProp removes the compiled handler. removeAttr isn't strictly necessary, but it removes the actual attribute (the string "javascript: ... ") too for greater consistency.
Upvotes: 1
Reputation: 123438
you can unbind()
handlers you only previously attached with bind()
(with jQuery 1.7+ you should use respectively off()
and on()
If this is not the scenario just simply destroy any click handler defined for that element in plain javascript
$(document).ready(function() {
document.getElementById('tdMinPriceOnNonStop0').click = function() { };
});
Upvotes: 0
Reputation: 3446
It's not obligatory, but you should provide the handler you wish to unbind:
function doStuff(){
//doing stuff
}
$('#tdMinPriceOnNonStop0').bind("click",doStuff);
//then
$('#tdMinPriceOnNonStop0').unbind("click",doStuff);
Upvotes: 1