0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

jQuery class属性操作の勉強

Posted at

お疲れ様です。

昨日提出した課題はあのあと合格判定をいただきましたので、今日は次に進み、class属性の操作について勉強しましたので、自分用のまとめです。

【class属性操作のメソッド】
addClass()…指定要素にclass属性を追加
removeClass()…指定要素からclass属性を削除
toggleClass()…指定要素に対しclass属性追加/削除の切替
hasClass()…指定要素にclass属性があるか確認する

addClassメソッド
71.png

removeメソッド
74.png
73.png

toggleClass/hasClassメソッド
75.png
76.png

htmlにclassを書き足したりしなくても、このメソッドを使えば、jsでclassを追加が可能になります。

これらを使えるようになると、以前監視を使って作成した自己紹介ページの、画像がじわりと表示される部分も、activeClassを追加するなどの書き方に変えて、scrollなどのイベントと組み合わせれば表示も可能そうかもと、勉強しながら思いました!
やりたいこと次第かもしれませんが、コードは1つではないということですね:relaxed:

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?