I can get this block of jquery to work on basic HTML in Codepen
However, it doesn't seem to be working when I try this on a SharePoint 2013 Publishing site.
I embedded the CSS and JQ in my master page the following way:
<!--SPM:<SharePoint:CssRegistration name="<% $SPUrl:~sitecollection/Style Library/Seattle/css/customnav.css %>" runat="server" after="corev15.css"/>-->
<!--SPM:<SharePoint:ScriptLink ID="ScriptLinkJQuery" name="~sitecollection/Style Library/Seattle/js/jquery-1.7.2.js" runat="server"/>-->
<!--SPM:<SharePoint:ScriptLink language="javascript" name="~sitecollection/Style Library/Seattle/js/test.js" runat="server"/>-->
I copied the JQuery from here. I then uploaded it through Designer to /Style Library/Seattle/js
The CSS works. I use the Network feature in F12 dev tools and I can see my test script and the jquery loading.
Here's my CSS:
.ms-breadcrumb-top {
background-color:black;
position:fixed;
top:65px;
left:0;
width:100%;
height:30px;
text-align: center;}
Here's my JQ:
$(window).scroll(function(){
if($(document).scrollTop() > 0)
{
$('.ms-breadcrumb-top').css({"display":"none"});
}
else{
$('.ms-breadcrumb-top').css({"width":"100%"});
}
});
What did I do wrong? How do I get this right?