Basic Image Swap on Mouseover

Basic Image Swap on Mouseover

Hello all!

I'm pretty new to front UI developement and have been using JQuery for about 6 months. Love it so far!

I am trying to get a image to swap out on mouseover and then go back on mouseout.  I found a basic example StackTrace but I cannot seem to get it to work.  When I mouseover, the image's scr changes to:  

assets/images/photo1 undefined...

I'm hoping another set of eyes can spot the issue and provide guidance.  Thanks!!

  1.     <img src="assets/images/photo-1.jpg" id="imgBrand1" />

  2.     <script src="assets/javascript/jquery-2.1.1.js"></script>
  3. <script>
  4.             $('document').ready(function ()
  5.         {
  6.             $(function ()
  7.             {
  8.                 $("#imgBrand1")
  9.                     .mouseover(function ()
  10.                     {
  11.                         var src = $(this).attr("src").match(/[^\.]+/) + "assets/images/photo-2.jpg";
  12.                         $(this).attr("src", src);
  13.                     })
  14.                     .mouseout(function ()
  15.                     {
  16.                         var src = $(this).attr("src").replace("assets/images/photo-2.jpg");
  17.                         $(this).attr("src", src);
  18.                     });
  19.             });
  20.         });

  21. </script>


Viewing source shows me (on mouseover)...

<img src="assets/images/photo-1undefinedundefinedundefinedundefined" id="imgBrand1">


Thanks!