gpt4 book ai didi

Jquery 对话框窗口示例不起作用

转载 作者:行者123 更新时间:2023-12-01 01:27:09 27 4
gpt4 key购买 nike

正在尝试学习Jquery,正处于放弃的边缘!!花了两天时间尝试显示一个对话框!

任何人都可以帮忙解释为什么这段代码不起作用吗?我只是在页面顶部打招呼!

jQuery:

<script src="js/jquery-1.5.2.min.js" type="text/javascript"></script>
<script src="js/jquery.ui.core.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function() {
var $dialog = $('#dialog')
//.html('This dialog will show every time!')
.dialog({
autoOpen: false,
title: 'Basic Dialog'
});
$('#opener').click(function() {
$dialog.dialog('open');
// prevent the default action, e.g., following a link
return false;
});
});
</script>

HTML

<div id="dialog">hello</div>
<button id="opener" style="margin-left:66px;margin-top:3px;font-size:11px;width:60px">Click</button>

最佳答案

确保您的 jQuery UI Core 文件已包含 Widget 工厂。看看:

http://jqueryui.com/download

即使您没有包含 jQuery UI CSS 文件,它仍然可以工作:

See jsFiddle demo

<小时/>

Try this exact code that I have out at jsBin:

<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8 />
<title>jQuery Dialog Demo</title>
<link rel="stylesheet" type="text/css" href="//ajax.aspnetcdn.com/ajax/jquery.ui/1.8.9/themes/cupertino/jquery-ui.css" />
</head>
<body>
<div id="dialog" style="display: none;">hello</div>
<button id="opener">Open Dialog</button>
<script type="text/javascript" src="//ajax.aspnetcdn.com/ajax/jquery/jquery-1.5.2.min.js"></script>
<script type="text/javascript" src="//ajax.aspnetcdn.com/ajax/jquery.ui/1.8.9/jquery-ui.min.js"></script>
<script type="text/javascript">
var $dialog = $("#dialog").dialog({ autoOpen: false, title: "Basic Dialog" });
$("#opener").click(function() { $dialog.dialog("open"); });
</script>
</body>
</html>

关于Jquery 对话框窗口示例不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10177606/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com