gpt4 book ai didi

javascript - 为什么开始选择了关闭按钮

转载 作者:行者123 更新时间:2023-11-27 22:50:14 25 4
gpt4 key购买 nike

我正在尝试 Jquery 对话框 Demo

但对话框显示已选中的 X,并且像蓝色光环。当点击外面就清楚了。但这样开始似乎很奇怪。

我将示例代码复制到单独的 HTML 中并具有相同的行为。

知道为什么会发生这种情况以及是否有解决方法?

enter image description here

源代码

<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>jQuery UI Dialog - Default functionality</title>
<link rel="stylesheet" href="//code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css">
<script src="//code.jquery.com/jquery-1.10.2.js"></script>
<script src="//code.jquery.com/ui/1.11.4/jquery-ui.js"></script>
<link rel="stylesheet" href="/resources/demos/style.css">
<script>
$(function() {
$( "#dialog" ).dialog();
});
</script>
</head>
<body>

<div id="dialog" title="Basic dialog">
<p>This is the default dialog which is useful for displaying information. The dialog window can be moved, resized and closed with the 'x' icon.</p>
</div>


</body>
</html>

最佳答案

根据 link@scott.gonzalez

In rc5 and previous releases the logic was: find the first tabbable element in the dialog and give it focus on open. In current SVN the logic is: find the first tabbable element in the following order: - content area - button pane - title bar and give it focus on open. This is done for accessibility to ensure that the dialog has focus when opened. We may change the logic after doing some testing to focus the actual dialog div if the close button is what would receive focus.

试试这个:

$("#dialog").dialog({
open: function() {
$(this).parents('.ui-dialog').attr('tabindex', -1)[0].focus();
}
});

关于javascript - 为什么开始选择了关闭按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38113222/

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