CSS Bootstrap关闭模式并转到链接 [英] CSS Bootstrap close modal and go to link

查看:122
本文介绍了CSS Bootstrap关闭模式并转到链接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

 < div class =modal fadeid =社区tabindex = -  1role =dialogaria-labelledby =myModalLabelaria-hidden =true> 
< div class =modal-content>
< button type =buttononclick =window.location.href ='#Pricing'data-dismiss =modal>关闭并转至定价< / button>
< / div>
< / div>

单击该按钮时,模式窗口关闭,但不会转到指定的正确部分#Pricing。

解决方案

如果链接处于同一页面,只需使用


  jQuery(function($){
$('#myModal')。on('hidden.bs.modal',function(e){
$('html,body')。animate({
scrollTop:$(#pricing)。offset()。top
},2000);
})
});

请参阅 jsfiddle


I have the following div for a modal box -

<div class="modal fade" id="Community" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-content">
        <button type="button" onclick="window.location.href='#Pricing'" data-dismiss="modal">Close and go to pricing</button>
    </div>
</div>

On click of the button the modal window closes but it doesn't go to the correct section indicated by #Pricing.

解决方案

if the link is in same page just use

jQuery(function($) {
    $('#myModal').on('hidden.bs.modal', function (e) {
        $('html, body').animate({
            scrollTop: $("#pricing").offset().top
        }, 2000);
    })
});

see this jsfiddle

这篇关于CSS Bootstrap关闭模式并转到链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆