jQuery>滚动到>突出显示滚动到的项目 [英] JQuery > ScrollTo > highlighting the item that was scrolled to

查看:68
本文介绍了jQuery>滚动到>突出显示滚动到的项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这似乎很简单,但我似乎无法弄清楚.我想更改使用JQuery的ScrollTo插件滚动到的元素的背景色.我正在使用onAfter设置.这就是我所拥有的:

This seems pretty simple, but I can't seem to figure it out. I want to change the background color of the element that was scrolled to using the ScrollTo plugin for JQuery. I'm using the onAfter setting. This is what I have:

$("#nav-inpage").localScroll({
  target:'body',
  offset: -50, // compensate for static super-nav
  hash: true,
  onAfter:function(){
    $(this.hash).css('background-Color' , '#ff0000');
  }
});

如果我将this.hash更改为此,目标(主体)的背景将变为红色.那么,如何处理要滚动到的哈希?

If I change this.hash to just this, the background of the target (body) turns red. So how do I address the hash that I'm scrolling to?

推荐答案

您需要实际获取哈希并将其用作ID选择器.

You need to actually fetch the hash and use it as an ID selector.

$(window.location.hash).css('background-Color' , '#ff0000');

这篇关于jQuery>滚动到>突出显示滚动到的项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆