Tag: 维度

jQuery:根据浏览器滚动条位置将css类添加到菜单项

我有一个菜单: Link 1 Link 2 Link 3 我希望这取决于浏览器的滚动条位置, “active”类是正确的 元素。 这就是我的看法: if ($(document).height() == 500) { $(‘#m1’).parent().addClass(‘active’). siblings().removeClass(‘active’); } if ($(document).height() == 1000) { $(‘#m2’).parent().addClass(‘active’). siblings().removeClass(‘active’); } if ($(document).height() == 1500) { $(‘#m2’).parent().addClass(‘active’). siblings().removeClass(‘active’); } 我对jQuery Dimensions属性不太熟悉,所以这段代码没有多大意义,但我希望你能理解。 如果有人能告诉我如何使这项工作,那将是非常酷的。 谢谢 :)

如何获得iframe的scrollTop

当window是iframe时,jQuery的scrollTop返回null。 有没有人能够弄清楚如何获得iframe的scrollTop? 更多信息: 我的脚本在iframe本身运行,父窗口在另一个域上,所以我无法访问iframe的ID或类似的东西