我有以下脚本,可以在我的导航项上为背景图像精灵设置动画:
$j(function() {
$j(".menu-item:not(.current-menu-item) .bottom_nav").hover( function () {
$j(this).animate( {
backgroundPosition : '0px 35px'}
, 300); }
, function () {
$j(this).animate( {
backgroundPosition : '0px 0px'}
, 600); }
);
});
我现在想从悬停脚本中排除第二个类。 我尝试将其添加为以下形式:
$j(".menu-item:not(.current-menu-item, .current-menu-parent) .bottom_nav").hover( function () {
和
$j(".menu-item:not('.current-menu-item, .current-menu-parent') .bottom_nav").hover( function () {
但两者都打破了悬停脚本。
jQuery .not()/:not selector documentation -
.not() 方法最终将为您提供更具可读性 选择,而不是将复杂的选择器或变量推送到 :not() 选择器过滤器。在大多数情况下,这是一个更好的选择。
$j(".menu-item").not(".current-menu-item,.current-menu-parent").find(".bottom_nav").hover()