[英]How do I load jquery snippets after full load of html?
完全加载html之后,有什么方法可以加载这些代码段吗? 如果在js文件之后加载摘要(设置为ASYNC加载),或者设置计时器,我会非常高兴。
<script>$(document).ready(function(){var modals = ['#bookings', '#studios', '#mygallery', '#social', '#reviews', '#articles', '#contactme', '#credits', '#pagemap', '#tsandcs', '#events'];if (window.location.hash && ~modals.indexOf(window.location.hash)) {$(window.location.hash).modal();}})</script>
<script>$(document).ready(function(){$("#myModal11").modal('show');});</script>
<script>$(".modal:not(.noclose) a").click(function(){$(this).closest(".modal").modal("hide");});</script>
您将它们放在文档中,准备就绪,
$(document).ready(function(){$("#myModal11").modal('show');});
只需将最后一个放在相同的就绪功能上,就可以了
尽管您也可以将它们放在这些功能之一中:
$(document).ready(function(){
// put all code here...
});
您可以尝试这种行为
希望这可以帮助 !
<html>
<head>
</head>
<body>
// My Html Here
<script>
$(document).ready(function(){
var modals = ['#bookings', '#studios', '#mygallery', '#social', '#reviews', '#articles', '#contactme', '#credits', '#pagemap', '#tsandcs', '#events'];
if (window.location.hash && ~modals.indexOf(window.location.hash)) {
$(window.location.hash).modal();
}
$("#myModal11").modal('show');
$(".modal:not(.noclose) a").click(function(){
$(this).closest(".modal").modal("hide");
});
});
</script>
</body>
//删除此click函数,并使用.on代替单个处理程序
$(".modal:not(.noclose)").on("click","a",function(){
$(this).closest(".modal").modal("hide");
});
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.