选择链接(内部或外部)时如何关闭模式对话框,以及如何设置一个或多个例外? [英] How do I close a modal dialog when a link (internal or external) is selected and how do I set one or more exceptions?
本文介绍了选择链接(内部或外部)时如何关闭模式对话框,以及如何设置一个或多个例外?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
每次访问者选择链接时,我希望对话框消失,页面向下滚动到特定的选定ID(不刷新).当然,我也必须设置一些例外!
Each time a visitor selects a link, I expect the dialog to disappear and page to scroll down to the specific - selected id (w/o refresh). Of course, I have to set some exceptions as well!
<div class="modal fade" id="basicModal6" tabindex="-1" role="dialog" aria-labelledby="basicModal6" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content fp">
<button type="button" class="ol close" data-dismiss="modal" aria-hidden="true"><i class="fa fa-times fa-2x red"></i></button>
<div class="heading text-center">
<h2>Title</h2>
<p>Text</p>
<footer class="f2 text-left wrap2">
<a href="#home">link A</a>
<a href="#bclass">link B</a>
<a href="#gclass">link C</a>
</footer>
</div>
</div>
</div>
</div>
推荐答案
对于内部链接,它将自动重定向到该位置,您只需要隐藏div.您可以这样做:
for internal links it will automatically redirect to the location, you just need to hide the div. You can do it by this:
如果您的链接是静态的:
If your links are static:
$(".modal a").click(function(){
$(this).closest(".modal").modal("hide");
});
如果是动态的:
$(document).on('click', '.modal a', function(){
$(this).closest(".modal").modal("hide");
});
或者,您也可以在链接上添加以下onclick:
Alternatively, You can also add this onclick on links:
onclick='$(this).closest(".modal").modal("hide")'
对于外部链接,它将被重定向到该链接,无需担心.
for external links it will be redirected to the link, no worries there.
这篇关于选择链接(内部或外部)时如何关闭模式对话框,以及如何设置一个或多个例外?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文