如何使用jQuery的叠加对话框作为反馈表单
16lz
2021-01-22
I'm trying to create a dialog (on click) for feedback. I've tried simple things first. Here's the fiddle
我正在尝试创建一个对话框(点击)以获得反馈。我先尝试过简单的事情。这是小提琴
$("#feed_win").dialog({
autoOpen:false;
});
$("#feedback").click( function() {
$( "#feed_win" ).dialog( "open" );
});
But every time on load the dialog contains are shown before the button click event. Any help will be useful.
但每次加载时,对话框都包含在按钮单击事件之前。任何帮助都会有用。
So, now i tried this.
所以,现在我尝试了这个。
<head>
<link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/themes/base/jquery-ui.css">
<script src="http://code.jquery.com/jquery-latest.min.js"></script>
<script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
<script type="text/javascript">
$("#feedback").button().click(function() {
$("#feed_win").dialog("open");
});
$("#feed_win").dialog({
autoOpen: false,
modal: true,
height: 300,
width: 400
});
</script>
</head>
<body>
<button id="feedback">Delete profile</button>
<div id="feed_win">
<h2>This is feedback form</h2>
<p>You can add your feedback here</p>
</div>
</body>
But the dialog div is displayed on page load. why? It should be displayed after clicking button.
但是对话框div显示在页面加载上。为什么?单击按钮后应显示。
1 个解决方案
#1
2
You need to include jQuery UI script in the head:
您需要在头部包含jQuery UI脚本:
<script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
Here is fiddle: DEMO
这是小提琴:DEMO
Everything else you wrote is good, just add that line
你写的其他所有内容都很好,只需添加该行即可
更多相关文章
- 开发学习Jquery实例---双击表格弹出模态对话框,编辑提交数据
- bootstrap,模态对话框,shown.bs.modal事件不会触发
- 当AJAX响应来自PHP文件时,如何显示以消息为中心的加载器图像&防止
- 为什么使用observe_field代码不能使用JQuery模型对话框?
- jQuery UI对话框调整大小关闭按钮
- 最简单jquery.ajax+php例子(对话框显示文本框输入内容),以小见大
- 打开后,JQuery ui对话框调整大小
- 使用jQuery确认对话框防止上的表单回发
- 我得到一个警告坏js小提琴配置