初心者向けjQuery入門

初心者向けjQuery入門講座です

未分類

jQuery removeClassクラスを削除する方法

投稿日:2017年8月9日 更新日:

jQuery removeClassクラスを削除する方法

jQuery removeClassクラスを削除する方法

htmlで設定したクラスを削除します。
cssで設定したクラスでも削除はできます。

$(“セレクタ “).removeClass(“削除するクラス名”)

サンプル

<html>
<head>

<script src=”jquery-3.2.1.js”></script>

<script>
$(document).ready(function(){

$(“h3:first-child “).removeClass(“red”)
$(“.red”).css({“font-size”:”72px”,”font-style”:”italic”,”background-color”:”red”})

});
</script>

<title>

</title>

</head>

<body>
<div>
<h3 class=”red”>red</h3>
<h3>Green</h3>
<h3>yellow</h3>
<h3>Blue</h3>
</div>
</body>

</html>

クラスが削除されて二つ目のcssが効いていませんね。

スポンサードリンク




スポンサードリンク




-未分類
-

執筆者:


comment

メールアドレスが公開されることはありません。 * が付いている欄は必須項目です

関連記事

no image

疑似クラスと疑似要素

疑似クラスと疑似要素 疑似クラス 疑似クラスとは疑似的に処理をセレクタに追加するものです。 :をつけます。 疑似クラス一覧 :active :any :checked :default :dir() …

no image

jQuery first-childとlast-childの勘違い

jQuery first-childとlast-child jQuery first-child first-childは一番最初の子要素を指定します。 $(“要素:first-child …

no image

jQuery parentとchildren親と子要素を取得する

Query parentとchildren親と子要素を取得する Query parent 親要素を取得する parentは指定した要素の親要素を取得します、 サンプル $(“セレクタ&#8 …

no image

jQuery animate要素をアニメーションさせる

jQuery animate要素をアニメーションさせる jQuery animate要素をアニメーションさせる animateの英語の意味は 生命を吹き込む,活気づける、活発にする、励ます、動画にする …

no image

jQuery mouseenterとmouseleaveマウスイベントの方法

jQuery mouseenterとmouseleaveマウスイベントの方法 jQuery mouseenterマウスを乗せた時のイベント方法 mouseenterはマウスを乗せた時に発生するイベント …