如何解决从打开的手风琴向浏览器中的URL添加哈希
我要问的一个问题是Smit Raval在……Link to anchor and open accordion上已经回答了这个已经得到最好回答的问题,他的回答非常适合从外部链接打开手风琴。但是,一旦打开该手风琴,我希望浏览器的URL以末尾的#anchor更新,因此现在有人可以使用锚链接将其添加为书签。因此,这是到目前为止的我的最终代码...感激不尽。
<script type="text/javascript">
(function($) {
$('.expand').click(function() {
$('.expand').removeClass('currentOn');
$('.collapse').slideUp('normal');
if($(this).next().is(':hidden') == true) {
$(this).addClass('currentOn');
$(this).next().slideDown('normal');
}
});
$('.expand').mouSEOver(function() {
$(this).addClass('over');
}).mouSEOut(function() {
$(this).removeClass('over');
});
$('.collapse').hide();
$('.open').slideDown('normal');
})( jQuery );
</script>
<!--This script is for linking from an external page and to open the accordion by ID-->
<script type="text/javascript">
(function($) {
$(document).ready(function(){
var hash = window.location.hash;
if (hash) {
var element = $(hash);
if (element.length) {
element.trigger('click');
$(window).scrollTop($accordionSection.offset().top);
}
}
});
})( jQuery );
</script>
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。