我在我的网页上放了一个JQuery Dialog,让访问者选择他们的语言。 它工作正常一段时间,现在它仍然有效,除了单击其中一个URL时框不关闭。 在标签中我有以下代码:
<script src="https://code.jquery.com/jquery-1.10.2.js"></script>
<script src="https://code.jquery.com/ui/1.10.4/jquery-ui.js"></script>
<link rel="stylesheet" href="https://code.jquery.com/ui/1.10.4/themes/smoothness/jquery-ui.css">
<script>
$(document).ready(function(){
$( "#hello" ).dialog( {width:350},{ autoOpen: true });
});
</script>
在标签中显示以下代码:
<div id="hello" title="Welkom - Welcome!"><p align="center"><font face="Georgia" size="4">
Kies uw taal - Choose your language</font></p>
<div align="center"><a href="index.html">Nederlands</a> <a href="indexeng.html">English</a></div></div>
弹出窗口显示,两个链接都有效,但正如我所说,唯一的问题是,当点击一个URL时,该框不会消失。 我从Udemy复制了这段代码并对其进行了一些调整,但是,作为我的新手,我一定忽略了一些东西。
如果有人能帮助我解决这个问题,我将非常感激。
答案 0 :(得分:0)
小部件有close
方法。单击按钮,您可以调用它来关闭模型。
例如,假设您在div上有类lang
,如:
$(function() {
$("#hello").dialog({
width: 350,
autoOpen: true
});
$('.lang a').on('click', function(event) {
event.preventDefault();
$("#hello").dialog('close');
});
});
<link rel="stylesheet" href="//code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="//code.jquery.com/ui/1.11.4/jquery-ui.js"></script>
<div id="hello">
<div class="lang" align="center">
<a href="index.html">Nederlands</a>
<a href="indexeng.html">English</a>
</div>
</div>