[英]Jquery Javascript only works on chrome and firefox, but not on IE
[英]jquery popup only works in ie and not in firefox
我有以下代碼。
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.11.0/themes/smoothness/jquery-ui.css" />
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.11.0/jquery-ui.min.js"></script>
<script type="text/javascript">
$(document).ready(function () {
$("#submit").click(function () {
$("#dialog").dialog({modal: true, height: 590, width: 1005 });
});
});
</script>
</head>
<body>
<a href="" id="submit">
<div id="dialog" title="Contact form">
<p>appear now</p>
</div>
</body>
</html>
當我在即運行此代碼時,它工作正常,並彈出窗口沒問題。 但是,當我在Firefox中運行它時,它只會刷新頁面。 有人知道如何解決此問題,為什么會發生?
我看到兩件事
1)使用event.preventDefault
防止鏈接默認行為(導航到href url,在本例中為當前頁面)
$("#submit").click(function (e) {
e.preventDefault():
$("#dialog").dialog({modal: true, height: 590, width: 1005 });
});
2)您a
標簽不正確,它永遠不會關閉。 不知道這是一個復制粘貼錯誤還是您的真實HTML。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.