LoginSignup
2
1

More than 5 years have passed since last update.

jQuery、マウスオーバーで色変化

Last updated at Posted at 2018-07-05

やってみよう!

デモイメージ↓
download.gif

以下コードです。

html
<div id="typo">マウス</div>
css
#typo {
    background-color: #64bcfc;
    color: #fff;
    font-weight: bold;
    font-size: 150px;
    text-align: center;
    line-height: 500px;
    height: 500px;
}
jQuery
//マウスオーバーしたときの色を指定
$("#typo").on("mouseover",function(){
    $("#typo").css({
        color: "#4dc0b2",
        backgroundColor: "#ffc042"
    });
});

//マウスアウトしたときに元の色に戻る
$("#typo").on("mouseout",function(){
    $("#typo").css({
        color: "",
        backgroundColor: ""
    });
});
2
1
2

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
2
1