jQuery removeClass()メソッド

❮jQueryHTML/ CSSメソッド

すべての<p>要素からクラス名「intro」を削除します。

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

定義と使用法

removeClass()メソッドは、選択した要素から1つ以上のクラス名を削除します。

注:パラメーターが指定されていない場合、このメソッドは選択された要素からすべてのクラス名を削除します。


構文

$(selector).removeClass(classname,function(index,currentclass))

Parameter Description
classname Optional. Specifies one or more class names to remove. To remove several classes, separate the class names with space

Note: If this parameter is empty, all class names will be removed
function(index,currentclass) Optional. A function that returns one or more class names to remove
  • index - Returns the index position of the element in the set
  • currentclass - Returns the current class name of selected elements

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


するaddClass()とremoveClass()を使用して1つのクラス名を削除し、新しいクラス名を追加する方法。


を使用して、選択した要素からクラスを削除します。


を削除する選択した要素からいくつかのクラス名を削除する方法。


❮jQueryHTML/ CSSメソッド