初心者向け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

jQuery prevとnext前と後の要素取得する

jQuery prevとnext前と後の要素取得する jQuery prev前の要素取得する prevは英語の略語で previous(以前の) 等です。 prevは指定した要素の前の要素を取得します …

no image

jQuery fadeInとfadeOutフェードインとフェードアウトする方法

jQuery fadeInとfadeOutフェードインとフェードアウトする方法 jQuery fadeInフェードインする方法 フェードインの英語の意味は次第に明るくなる、次第にはっきりするです。 f …

no image

jQuery mouseoverとmouseoutマウスイベントの方法

Query mouseoverとmouseoutマウスイベントの方法 Query mouseoverマウスを乗せた時のイベントの方法 mouseoverはマウスを要素に乗せた時に発生するイベントです。 …

no image

jQuery beforeとafterの違いと要素の追加

jQuery beforeとafterの違いと要素の追加 jQuery beforeとafterの違い beforeとafterは基本的な動作は似てます。 共通してるのは要素を追加することです。 違う …

no image

jQuery prependとappendの違いと要素の追加

jQuery prependとappendの違いと要素の追加 jQuery prependとappendの違い prependとappendの違いはprependは指定した要素の要素の先頭に追加されま …