removeClass():要素のクラス(class)を削除する
2016/04/19
要素のクラス(class)を削除するの書式
$("要素名").removeClass("クラス名");
要素のクラス(class)を削除する場合は、
$("要素名").removeClass("クラス名");を記述します。
removeClassメソッドの第1引数にクラス名を代入となります。
具体例(要素のクラス(class)を削除するのサンプルコード)
サンプルでは以下の事をしてます。
1.removeClassメソッドを使って、クラスの削除。
<!DOCTYPE html>
<html lang="ja">
<head>
<meta charset="utf-8">
<title></title>
<style type="text/css">
<!--
body {background-color: #ffffff;}
-->
.classAttention { color: #ff0000; font-weight: bold; }
</style>
<script src="../../js/jquery-1.12.2.min.js"></script>
<script>
$(function(){
$("p").removeClass("classAttention");
});
</script>
</head>
<body>
<p class = "classAttention">pタグの文字</p>
<div id = "resultDiv">上のPタグの文字はどんな感じ?</div>
</body>
</html>
要素のクラス(class)を削除するのサンプルコードの結果
