on() 不支持hover事件
因为 .hover() 是 jQuery 自己定义的事件… 是为了方便用户绑定调用 mouseenter 和 mouseleave 事件而已,它并非一个真正的事件,所以当然不能当做 .bind() 中的事件参数来调用。
$("body").on("mouseenter","#standard-answer tr",function(){ var n = $(this).index(); $("body").find("#student-answer tr").eq(n).css("background","#AFFCF7"); }); $("body").on("mouseleave","#standard-answer tr",function(){ var n = $(this).index(); $("body").find("#student-answer tr").eq(n).css("background",""); });
【推荐】还在用 ECharts 开发大屏?试试这款永久免费的开源 BI 工具!
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步