当 URL 哈希 # 更改时将 div 附加到正文 [英] Append div to body when URL hash # changes
问题描述
我正在使用 curtain.js 并希望保留一个 DIV(保存导航) 始终可见,除非用户正在查看第一个面板,即页面顶部.
I'm using curtain.js and would like to keep a DIV (which holds navigation) visible at all times except for when the user is looking at the very first panel, i.e. at the top of the page.
当前 DIV 位于面板二中
Currently the DIV resides within panel two
我正在考虑在您滚动页面时使用哈希更改来触发对正文的附加.Curtain.js 为每个面板创建一个单独的 URL,每次面板显示时 URL 都会更改.
I'm thinking perhaps of using the hash change as you scroll through the page to trigger an append to the body. Curtain.js creates an individual URL for each panel and the URL changes each time a panel is brought into view.
我可以将 div 附加到正文(如下),但我需要确定何时执行此操作,但我不确定如何执行?有人可以帮我吗?
I can append the div to the body (below) but I need to work out when to do this but I am unsure how? Could anyone help me out?
$("body").append($('.nav-wrap'));
推荐答案
好吧,而不是使用一些 hacky 解决方案,在对插件文件进行了大量挖掘之后,我只是添加了:
Ok well instead of using some hacky solution, after much digging around in the plugin's file, I just added:
$("body").append($('.nav-wrap'));
到第 491 行的 setHash
函数.效果很好.
to the setHash
function on line 491. Works a treat.
这篇关于当 URL 哈希 # 更改时将 div 附加到正文的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!