[英]jQueryUI: dialog() title bar not changing
See this fiddle: http://jsfiddle.net/590hbj9y/5/ 看到这个小提琴: http : //jsfiddle.net/590hbj9y/5/
Clicking the different buttons generates a different dialog body, but the dialog title is unchanged. 单击不同的按钮会生成不同的对话框主体,但是对话框标题不变。 How can I get the title to change? 如何更改标题?
Here's the code from the fiddle. 这是小提琴中的代码。 (Would be nice if StackOverflow wrote an automatic importer for this!) (如果StackOverflow为此编写了一个自动导入器,那就太好了!)
HTML 的HTML
<section id="dialog" title="hi">Hello</section>
<input type="button" msg="Sup" value="Say Sup">
<input type="button" msg="Yo" value="Say Yo">
<input type="button" msg="Foo" value="Say Foo">
JS JS
function showMessage(evt) {
var msg = $(evt.target).attr('msg');
var dialog = $("#dialog");
dialog.attr('title', "Showing " + msg);
dialog.text(msg);
dialog.dialog();
}
$(function () {
$("input").click(showMessage);
});
CSS 的CSS
#dialog {
display: none;
}
You need to pass the title as an option. 您需要通过标题作为选项。
http://api.jqueryui.com/dialog/#option-title http://api.jqueryui.com/dialog/#option-title
function showMessage(evt) { var msg = $(evt.target).attr('msg'); var dialog = $("#dialog"); dialog.text(msg); dialog.dialog({ title: "Showing "+ msg }); } $(function () { $("input").click(showMessage); });
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script> <script src="https://code.jquery.com/ui/1.11.1/jquery-ui.min.js"></script> <link rel="stylesheet" type="text/css" href="https://code.jquery.com/ui/1.11.1/themes/black-tie/jquery-ui.css"/> <section id="dialog" title="hi">Hello</section> <input type="button" msg="Sup" value="Say Sup"> <input type="button" msg="Yo" value="Say Yo"> <input type="button" msg="Foo" value="Say Foo">
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.