LoginSignup
0
0

jQueryで写真をマウスオーバーで切り替える

Posted at

jQueryで写真にカーソルが当たっている間、別の写真に切り替わる(マウスを画像のそとに当てると元の画像に戻る)をする方法

・jQueryのmauseoverとmouseoutを使用する

$(function() {
$("img").mouseover(function() {
$(this).attr("src","./images/suisen.jpg").attr("alt","水仙");
}).mouseout(function() {
$(this).attr("src","./images/bouquet.jpg").attr("alt","ブーケ");
});
});

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