jquery – 骨干事件

嗨,我想知道如何使用骨干和js处理删除悬停状态

目前我有

events: {
  "hover .info"   : "hover"
},hover:(e) =>
  $(e.currentTarget).css("background-color","#333")

我想知道如何处理我将鼠标从元素与.info类移动的事件

如果我在标准的咖啡脚本里面做到这一点在悬停:事件处理程序,它需要2个悬停,它的工作.

我基本上想模仿

$(".info").hover(
    function() {
       $(this).css("background-color","#333")
    },function() {
       $(this).css("background-color","#F3F")
    },});

谢谢

解决方法

一个版本的 hover() that takes one callback function

Description: Bind a single handler to the matched elements,to be executed when the mouse pointer enters or leaves the elements.

这是由Backbone使用的悬停版本.所以你可以使用toggleClass和几个CSS类来处理这个问题,而不是直接搞砸css:

hover:(e) =>
  $(e.currentTarget).toggleClass('dark-gray')

认情况下,认的#F3F颜色将在元素上设置,您可以:

.dark-gray {
  background-color: #333
}

在你的样式表.如果由于某种原因无法使用toggleClass,则必须单独绑定到mouseenter和mouseleave.

相关文章

页面搜索关键词突出 // 页面搜索关键词突出 $(function () {...
jQuery实时显示日期、时间 html: <span id=&quot...
jQuery 添加水印 <script src="../../../.....
中文:Sys.WebForms.PageRequestManagerParserErrorExceptio...
1. 用Response.Write方法 代码如下: Response.Write(&q...
Jquery实现按钮点击遮罩加载,处理完后恢复 思路: 1.点击按...