粘滞菜单更改徽标

时间:2017-09-16 18:40:58

标签: javascript jquery html css

我正在网站上工作,它有一个粘性菜单,我需要做的是在滚动时更改徽标并使用粘贴标题。

标头就是那样

<header id="header" class="float-panel" data-top="0" data-scroll="100">

一旦我向下滚动,课程更改为固定

<header id="header" class="float-panel  fixed" data-top="0" data-scroll="100">

我需要更改徽标一旦用css或jquery修复,我启用目标,我尝试使用以下

if($("#header.float-panel").hasClass('fixed'))

这是徽标div

<div class="logo"><!-- logo -->



    <a href="http://"><img src="Logo-Full_Pos.png" alt=""></a><h6 class="site-title"><a href="http://.com/" rel="home">g</a></h6>                           
                            </div>

由于

1 个答案:

答案 0 :(得分:2)

这行代码:if($(“#header.float-panel”)。hasClass('fixed'))只会运行onload。您需要使用滚动事件:https://api.jquery.com/scroll/以确保在菜单修复时命中if语句。

相关问题