简体   繁体   中英

ActionLink image hover button effect with mouse event

I want to create button effect ie mouse_over, mouse_leave and mouse_click using the jQuery. I have link written in ActionLink in mvc 4 using visual studio 2012. so i want to change image with slightly bigger image and when mouse leave, it go back to original image and some kind of effect when link is click...

@Html.ActionLink(" ", "index1", "Home","index1", new {id="a1", @class="dashboard_function_icons"})

@Html.ActionLink(" ", "index2", "Home","index2", new {id="a2", @class = "dashboard_function_icons"})

@Html.ActionLink(" ", "index3", "Home","index3", new {id="a3", @class = "dashboard_function_icons"})

CSS CODE
---------
.dashboard_function_icons {

   display:block;
   height: 15px;
   width: 20px;
   padding-left: 80px;
   padding-bottom: 80px;
   margin-top:10px;
   margin-left:10px;
   float:left;
}

  #a1 {
    background: url("../Images/people.png") no-repeat;
  }

  #a2 {
    background: url("../Images/ball.png") no-repeat;
  }

  #a3 {
    background: url("../Images/save.png") no-repeat;
    }

 jQuery
 -------
 $(".dashboard_function_icons").hover(
        function () { $(this).},
        function () { $(this).;});

您可以在悬停回调中使用.addClass.removeClass函数。

You can achieve that just using CSS with :hover pseudo-class and a sprite image, and just moving the sprite image in the background with css. see this article

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM