ActionLink图像悬停按钮效果与鼠标事件

时间:2012-12-25 12:04:16

标签: javascript asp.net-mvc jquery-ui css3 html.actionlink

我想使用jQuery创建按钮效果,即mouse_over,mouse_leave和mouse_click。我有使用visual studio 2012在mvc 4中用ActionLink编写的链接。所以我想用稍大的图像更改图像,当鼠标离开时,它会回到原始图像并且当链接点击时会产生某种效果......

@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).;});

2 个答案:

答案 0 :(得分:0)

您可以在悬停回调中使用.addClass.removeClass功能。

答案 1 :(得分:0)

你只需使用CSS即可实现:hover伪类和精灵图像,只需用css在后台移动精灵图像。见this article