jQuery unbind()メソッド

❮jQueryイベントメソッド

すべての<p>要素のすべてのイベントハンドラーを削除します。

$("button").click(function(){
  $("p").unbind();
});

定義と使用法

unbind()メソッドはバージョン3.0で非推奨になりました。代わりにoff()メソッドを使用してください 。

unbind()メソッドは、選択した要素からイベントハンドラーを削除します。

このメソッドは、すべてまたは選択したイベントハンドラーを削除したり、イベントの発生時に指定した関数の実行を停止したりできます。

このメソッドは、イベントオブジェクトを使用してイベントハンドラーのバインドを解除することもできます。これは、イベント自体のバインドを解除するために使用されます(イベントが特定の回数トリガーされた後にイベントハンドラーを削除するなど)。

注:パラメーターが指定されていない場合、unbind()メソッドは、指定された要素からすべてのイベントハンドラーを削除します。

注: unbind()メソッドは、jQueryにアタッチされたすべてのイベントハンドラーで機能します。


構文

$(selector).unbind(event,function,eventObj)

Parameter Description
event Optional. Specifies one or more events to remove from the elements.
Multiple event values are separated by space.
If this is the only parameter specified, all functions bound to the specified event will be removed.
function Optional. Specifies the name of the function to unbind from the specified event for the element
eventObj Optional. Specifies the event object to remove to use. The eventObj parameter comes from the event binding function

自分で試してみてください-例


のバインドを解除するunbind()メソッドを使用して、要素の指定されたイベントから特定の関数のバインドを解除する方法。


を解除する削除するイベントオブジェクトを指定します。


❮jQueryイベントメソッド